public
Last active — forked from sublimator/reverseselections.py

  • Download Gist
expandselection.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#coding: utf8
#################################### IMPORTS ###################################
 
# Sublime Libs
import sublime
import sublime_plugin
 
################################################################################
 
class ExpandselectionCommand(sublime_plugin.TextCommand):
def run(self, edit, direction="left"):
view = self.view
for sel in view.sel():
if direction == "left":
if sel.b > sel.a:
na = sel.b
nb = sel.a
else:
na = sel.a
nb = sel.b-1
else:
if sel.b < sel.a:
na = sel.b
nb = sel.a
else:
na = sel.a
nb = sel.b+1
view.sel().add(sublime.Region(na, nb))
view.show(view.sel())
 
################################################################################
keys.sublime-keymap
JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
[
{
"keys": ["ctrl+left"],
"command": "expandselection",
"args": {
"direction": "left"
}
},
{
"keys": ["ctrl+right"],
"command": "expandselection",
"args": {
"direction": "right"
}
}
]

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.