-
-
Save rcherny/4afdaa0183761d2f1a07e8c9c558c569 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 CursorCommand(sublime_plugin.TextCommand): | |
| saved_cursors = set() | |
| def run(self, edit, action="add"): | |
| view = self.view | |
| cursors = view.sel(); | |
| if action == "add": | |
| for cursor in cursors: | |
| self.saved_cursors.add(cursor.begin()) | |
| elif action == "show": | |
| cursors.clear() | |
| cursors.add_all(self.saved_cursors) | |
| self.saved_cursors.clear() | |
| elif action == "clear": | |
| self.saved_cursors.clear() | |
| elif action == "remove": | |
| for cursor in cursors: | |
| try: | |
| self.saved_cursors.remove(cursor.begin()) | |
| except KeyError: | |
| pass | |
| self.highlight_regions() | |
| def highlight_regions(self): | |
| regions = [sublime.Region(x, x) for x in self.saved_cursors] | |
| self.view.add_regions("saved_cursor_region", regions, | |
| "keyword", "", sublime.DRAW_EMPTY) |
This file contains hidden or 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
| [ | |
| { "keys": ["f12"], "command": "cursor", "args": {"action": "add"}}, | |
| { "keys": ["f11"], "command": "cursor", "args": {"action": "show"}}, | |
| { "keys": ["f10"], "command": "cursor", "args": {"action": "clear"}}, | |
| { "keys": ["f9"], "command": "cursor", "args": {"action": "remove"}} | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment