title: Algorithm for auto-indenting brackets in code
body: <p>im working on a code-editor (WinForms) and i want to know how to do function of { and } specifically the auto-indention using brackets (open and close) like in actual code editor .</p>
  
  <blockquote>
    <p>---|> { and }</p>
  </blockquote>
  
  <p>like this 1:</p>
  
  <p><img src="https://i.stack.imgur.com/yoWbR.png" alt="enter image description here"></p>
  
  <p>Editor was a richtextbox named rtb.</p>