Home Download Buy Blog Forum Support

MarkLinesContaining - Bookmark lines from custom panel

MarkLinesContaining - Bookmark lines from custom panel

Postby robertcollier4 on Tue Feb 26, 2013 2:50 pm

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.

Code: Select all
{ "keys": ["alt+m"], "command": "mark_lines_containing" },


File: mark_lines_containing.py
Code: Select all
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
Last edited by robertcollier4 on Sat Mar 02, 2013 9:15 am, edited 5 times in total.
robertcollier4
 
Posts: 154
Joined: Sun Feb 24, 2013 5:37 pm

Re: MarkLinesContaining - Bookmark lines from search term

Postby planet on Tue Feb 26, 2013 5:02 pm

Thank you, very nice plugin!
planet
 
Posts: 25
Joined: Fri Feb 17, 2012 12:30 pm

Re: MarkLinesContaining - Bookmark lines from search term

Postby highend on Fri Mar 01, 2013 7:46 am

Thank you, very nice plugin


+1 :D
highend
 
Posts: 94
Joined: Fri Jan 20, 2012 2:47 pm

Re: MarkLinesContaining - Bookmark lines from search term

Postby robertcollier4 on Sat Mar 02, 2013 8:59 am

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
robertcollier4
 
Posts: 154
Joined: Sun Feb 24, 2013 5:37 pm


Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 13 guests