Sublime Forum

MarkLinesContaining - Bookmark lines from custom panel

#1

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]

0 Likes

[ST3] StickySearch - persistent highlight of selected text
MarkFromFindpanel - Bookmark lines from find panel
#2

Thank you, very nice plugin!

0 Likes

#3

+1 :smiley:

0 Likes

#4

For those who like this plugin, even better now is MarkFromFindpanel since it doesn’t have to create a different panel but rather re-uses the existing find panel:
MarkFromFindpanel - Bookmark lines from find panel

0 Likes