There is view.sel() but I can't figure out how to use it. Using the following codes as example, how do you make it work only in selection of text?
def run(self, edit):
str = self.view.find_all(" foo ")
for r in str: