I’m making some sort of progress with the following code. It manages to find the words and change their formatting, but with a weird background?! I tried a scope of “comment” but a similar effect occurs(?).
[code]import sublime, sublime_plugin
class ExampleCommand(sublime_plugin.EventListener):
# def on_query_completions(self, view, prefix, locations):
# if not view.match_selector(locations[0],‘text.html - source’):
# return ]
def on_modified(self, view):
sel = view.sel()[0]
pt = sel.begin()
if not view.match_selector(pt, 'source.python'):
print 'not Python'
return
if view.find("import\s+sublime",0) is None:
print 'not using Sublime'
return
edit = view.begin_edit()
print 'here'
api_regions = view.find_all("view|sel|begin")
print api_regions
view.add_regions('my_key', api_regions, "storage.type.class.python")
view.end_edit(edit)[/code]