I often need to look at logs. I needed a way to quickly highlight different parts of the logs. I created a plugin for Sublime Text to do that.
Here are instructions to create a plugins.
Here is my plugin:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime | |
import sublime_plugin | |
class ReggaeCommand(sublime_plugin.TextCommand): | |
def run(self, edit, pattern_args): | |
p = 0 | |
colours = ["region.cyanish", "region.orangish", "region.bluish"] | |
icons = ["dot", "circle"] | |
for pattern_arg in pattern_args: | |
region_key = 'regexreg'+str(p) | |
regionst = self.view.get_regions(region_key) | |
if regionst: | |
self.view.erase_regions(region_key) | |
regions = self.view.find_all(pattern_arg) | |
self.view.add_regions(region_key, regions, colours[p % len(colours)], icons[p % len(icons)], sublime.DRAW_STIPPLED_UNDERLINE) | |
p = p + 1 |
You can invoke it with
view.run_command("reggae", {"pattern_args": ["pattern 1", "pattern 2"]})