Skip to content

Instantly share code, notes, and snippets.

@diego898
Last active March 22, 2017 18:23
Show Gist options
  • Save diego898/ab8f2a36542c074e74e6b5d0691e38c5 to your computer and use it in GitHub Desktop.
Save diego898/ab8f2a36542c074e74e6b5d0691e38c5 to your computer and use it in GitHub Desktop.
A simple ST plugin to highlight text like `\todo`, `@todo`, `@author_name` - originally from - https://github.com/SublimeText/LaTeXTools/issues/1052#issuecomment-287898776
import sublime
import sublime_plugin
class HighlightTodoListener(sublime_plugin.EventListener):
def highlight_todo(self, view):
# only highlight tex files
if not view.score_selector(0, "text.tex"):
return
# adapt this regex as you wish
commands = ["todo"]
annotations = ["todo", "TODO", "note", "diego"]
regions = view.find_all(
r"\\(?:{com})\b|"
r"@(?:{anon})\b"
.format(com="|".join(commands), anon="|".join(annotations))
)
view.erase_regions("td_highlighter")
view.add_regions("td_highlighter", regions, "keyword", "bookmark"
# , flags=sublime.DRAW_OUTLINED
)
on_load = highlight_todo
on_post_save = highlight_todo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment