Skip to content

Instantly share code, notes, and snippets.

@ryukzak
Created January 5, 2012 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryukzak/1567715 to your computer and use it in GitHub Desktop.
Save ryukzak/1567715 to your computer and use it in GitHub Desktop.
import sublime, sublime_plugin
class ClearMarkCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command("clear_bookmarks", {"name": "mark"})
self.view.settings().set('with_marker', False)
class DoAfterMarkCommand(sublime_plugin.TextCommand):
def run(self, edit, command, args = {}):
self.view.run_command("clear_mark")
self.view.run_command(command)
class SetMarkCommand(sublime_plugin.TextCommand):
def run(self, edit):
if not self.view.get_regions("mark"):
mark = [s for s in self.view.sel()]
self.view.add_regions("mark", mark, "mark", "dot",
sublime.HIDDEN | sublime.PERSISTENT)
self.view.settings().set('with_marker', True)
else:
self.view.run_command("clear_mark")
class MarkDetector(sublime_plugin.EventListener):
def on_selection_modified(self, view):
mark = view.get_regions("mark")
if mark:
view.run_command("select_to_mark")
def on_modified(self, view):
mark = view.get_regions("mark")
if mark:
view.run_command("clear_mark")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment