String.IndexOf finds only the first occurrence in the string, so you need to repeat teh search using the overloaded methods.
public static class MyExtensions
{
public static List<int> AllIndexesOf(this string s, string lookFor)
{
List<int> indexes = new List<int>();
int index = s.IndexOf(lookFor);
int len = lookFor.Length;
while (index >= 0)
{
indexes.Add(index);
index = s.IndexOf(lookFor, index + len);
}
return indexes;
}
}
Will find them all:
List<int> x = "abcdabceab".AllIndexesOf("abc");
will return a List of two indexes.
But ... you can't select more than one text area - you will have to manually (and temporarily) highlight them yourself, or provide a "find next" function as some text editors do.