title: Color specific words in RichtextBox
body: <p>How can I make, that when the user types specific words like 'while' or 'if' in a rich textbox, the words will color purple without any problems? I've tried diffrent codes, but none of them were usable. The codes were like below:</p>
  
  <pre><code>if (richTextBox.Text.Contains("while"))
    {
      richTextBox.Select(richTextBox.Text.IndexOf("while"), "while".Length);
      richTextBox.SelectionColor = Color.Aqua;
    }
  </code></pre>
  
  <p>Also, I want that when the user removes the word or removes a letter from the word, the word will color back to its default color. I'm making a program with a code editor in it.</p>
  
  <p>I am using Visual c#.</p>
  
  <p>Thank you.</p>