Skip to content

Instantly share code, notes, and snippets.

@robertcollier4
robertcollier4 / expand_selection_to_delims.py
Last active December 15, 2015 14:39
expand_selection_to_delims for SublimeText, use with { "keys": ["ctrl+shift+d"], "command": "expand_selection_to_delims"},
class ExpandSelectionToDelimsCommand(sublime_plugin.TextCommand):
def run(self, edit):
begindelims = ["\"", "\'", "(", "<", "[", "{"]
enddelims = ["\"", "\'", ")", ">", "]", "}"]
view = self.view
oldSelRegions = list(view.sel())
for thisregion in oldSelRegions:
thisRegionBegin = thisregion.begin() - 1
thisRegionEnd = thisregion.end()
if( (thisregion.begin() != thisRegionEnd) and (view.substr(thisRegionBegin) in begindelims) ):