It worked, I want the document to highlight all ocurrences of a given string while keeping the style for the rest of the words.
The code I'm using is as follows:
var language = syntaxEditor.Document.Language;
language.IsUpdating = true;
var style = new HighlightingStyle("H2", null, Color.Black, Color.LightBlue, DefaultableBoolean.Default, DefaultableBoolean.Default, HighlightingStyleLineStyle.Default);
var lexicalPatternGroup = new LexicalPatternGroup(LexicalPatternType.Explicit, "T2", style, textToSearch);
if (isMatchCase)
lexicalPatternGroup.CaseSensitivity = CaseSensitivity.Sensitive;
((DynamicLexicalState)language.DefaultLexicalState).LexicalPatternGroups.Insert(0, lexicalPatternGroup);
if(!language.HighlightingStyles.Contains(style))
language.HighlightingStyles.Add(style);
language.IsUpdating = false;
[Modified 11 years ago]