Skip to content

Instantly share code, notes, and snippets.

@MaciekBaron
Last active December 19, 2015 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaciekBaron/5958554 to your computer and use it in GitHub Desktop.
Save MaciekBaron/5958554 to your computer and use it in GitHub Desktop.
Simple plugin for highlighting TODOs and similar things
import sublime, sublime_plugin
combinations = (('todo', '(.*)TODO:(.*)', 'string'), ('fix','(.*)FIX:(.*)', 'invalid'))
class HighlightText(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
for combination in combinations:
regions = view.find_all(combination[1],0)
view.add_regions(combination[0], regions, combination[2] , '')
class HighlightOnSave(sublime_plugin.EventListener):
def on_activated(self, view):
view.run_command("highlight_text")
def on_modified_async(self, view):
view.run_command("highlight_text")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment