Aug 21, 2012 at 2:38 AM
Edited Aug 22, 2012 at 1:32 AM
This question gets asked SO much that I thought it was time to answer it once and for all. Looking at the Notepad++ source code (FindReplaceDlg.cpp) it's clear that they use modern indicators to highlight all instances of a given word. The equivalent
in ScintillaNET would be something like this:
scintilla.Indicators.Style = IndicatorStyle.RoundBox;
scintilla.Indicators.Color = Color.Green;
foreach (Range r in scintilla.FindReplace.FindAll("this"))
Yup, it's that easy.
Using indicators instead of styles has the advantage that they won't get lost when the document is restyled. You can also search for text with a given indicator so you could use that to jump from one instance of the word to another. And oh, so much more!
I'll leave it to the reader to figure out how to clear indicators.
P.S. - Downloading and browsing the Notepad++ source code is how I learn these things ;)