Thanks to the people on this forum, I have completed my first plugin. This command will ask you to type in your search term in a bottom panel and then will add bookmarks to all lines containing that search term. After that you can use the hotkeys for “prev_bookmark” and “next_bookmark” to navigate through your search results. And then you can use the hotkey for “toggle_bookmark” or “clear_bookmarks” to clear them.
This is super handy and is my preferred way to search and go through / process search results.
{ "keys": "alt+m"], "command": "mark_lines_containing" },
File: mark_lines_containing.py
[code]import sublime, sublime_plugin
class MarkLinesContainingCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.show_input_panel("Mark Lines Containing:", "", self.on_done, None, None)
pass
def on_done(self, text):
ExistingBookmarks = self.window.active_view().get_regions("bookmarks")
RegionsResult = ExistingBookmarks + self.window.active_view().find_all(text, sublime.IGNORECASE | sublime.LITERAL)
self.window.active_view().add_regions("bookmarks", RegionsResult, "bookmarks", "bookmark", sublime.HIDDEN | sublime.PERSISTENT) # valid gutter icons are dot, circle, bookmark and cross
[/code]