Skip to content

Instantly share code, notes, and snippets.

@c-spencer
Forked from sublimator/reverseselections.py
Created July 30, 2011 10:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c-spencer/1115398 to your computer and use it in GitHub Desktop.
Save c-spencer/1115398 to your computer and use it in GitHub Desktop.
#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": ["ctrl+left"],
"command": "expandselection",
"args": {
"direction": "left"
}
},
{
"keys": ["ctrl+right"],
"command": "expandselection",
"args": {
"direction": "right"
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment