Старый способ
private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Back)
{
var z = this.richTextBox1.SelectionStart;
var r = richTextBox1.Find(" ", 0, z, RichTextBoxFinds.None | RichTextBoxFinds.Reverse);
var q = this.richTextBox1.Text.Substring(r + 1, z - r - 1);
switch (q)
{
case "test":
this.richTextBox1.SelectionStart = r + 1;
this.richTextBox1.SelectionLength = z - r - 1;
this.richTextBox1.SelectionColor = Color.Black;
this.richTextBox1.SelectionStart += this.richTextBox1.SelectionLength;
this.richTextBox1.SelectionLength = 0;
//e.Handled = true;
break;
default:
this.richTextBox1.SelectionStart = z;
break;
}
}
}