Hello. I have the following Python code to find the previous occurrence of a word:
new_regions = self.view.find_all(prev_wd, sublime.LITERAL)
new_region = None
for r in reversed(new_regions):
if r.begin() < prev_pt:
new_region = r
break
if new_region:
where prev_pt is the begin-point of the word I’m looking for (prev_wd).
Well, it works, but I’m assuming there is a neater, more efficient, way of doing this?
An alternative, but messier approach, might be to keep subtracting some number (10) for a value x, using find() forward from this x-point. But perhaps a single call to find_all will always be more efficient than repeated calls to find? Andy.