[code]#coding: utf8
#################################### IMPORTS ###################################
Sublime Libs
import sublime_plugin
################################################################################
class PopSelections(sublime_plugin.TextCommand):
“”"
{
“keys”: “ctrl+alt+up”], “args”: {“forward”: false },
“command”: “pop_selections”,
“context”:
{
“key”: “selection_empty”,
“operator”: “equal”, “operand”: false, “match_all”: false
}
]
},
{
“keys”: “ctrl+alt+down”], “args”: {“forward”: true },
“command”: “pop_selections”,
“context”:
{
“key”: “selection_empty”,
“operator”: “equal”, “operand”: false, “match_all”: false
}
]
}
“”"
def is_enabled(self, forward):
return len(self.view.sel()) > 1
def run(self, edit, forward=True):
view = self.view
view.sel().subtract(view.sel()[0 if forward else -1])
################################################################################
[/code]
If you are like me, you typically use the select_lines
command only with empty selections. I just bound over the bindings for that with something that pops selections. You might wanna binding for when the selections are empty.
You might also like this command in combination with split by lines:
[code]class ModuloSelections(sublime_plugin.TextCommand):
def run(self, edit, m=2, n=1):
view = self.view
for i, sel in enumerate(list(view.sel())):
if not i % int(m) == int(n) - 1:
view.sel().subtract(sel)
[/code]
Say you want the 1st of every 2 selections you’d run a binding like so:
{
"args": {
"m": "2",
"n": "1"
},
"command": "modulo_selections",
"context": ],
"keys":
"ctrl+shift+5"
]
},
Change n
to 2 for a binding for the 2nd of every 2 selections. You get the gist …