-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalt_click_cursor_plugin.py
24 lines (21 loc) · 1.26 KB
/
alt_click_cursor_plugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import sublime
import sublime_plugin
class CtrlAltClickCursorPlugin(sublime_plugin.EventListener):
def on_text_command(self, view, command_name, args):
if command_name == "drag_select" and "by" in args and args["by"] == "words" and "additive" in args and args["additive"] and sublime.platform() == "windows":
# Ctrl+Alt+Click detected when selecting words on Windows
# Remove the default selection and add a new cursor
view.sel().clear()
for region in view.get_regions("ctrl_alt_click_cursors"):
view.sel().add(region)
view.erase_regions("ctrl_alt_click_cursors")
return ("noop", None)
return None
def on_post_text_command(self, view, command_name, args):
if command_name == "drag_select" and "by" in args and args["by"] == "words" and "additive" in args and args["additive"] and sublime.platform() == "windows":
# Ctrl+Alt+Click detected when selecting words on Windows
# Store the new cursor position as a region
region = view.sel()[0]
regions = view.get_regions("ctrl_alt_click_cursors")
regions.append(region)
view.add_regions("ctrl_alt_click_cursors", regions, "string", "", sublime.HIDDEN)