Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.
This script selects all the occurrences in the current document of the given regex. I'm posting it here as it's coming up a few times and so people might find it useful, if even they don't use Python Script normally.
It operates on either the current selection if something is selected, or over the whole document if there's no current selection.
first = True
def found(line, m):
pos = editor.positionFromLine(line)
editor.setSelection(pos + m.end(), pos + m.start())
first = False
editor.addSelection(pos + m.end(), pos + m.start())
regex = notepad.prompt('Search for:', 'Select all results')
lines = editor.getUserLineSelection()
editor.pysearch(regex, found, 0, lines, lines)