PKW4=/PPDefault.sublime-keymap PKW4=) README.txtStripSelection plugin This command removes leading and trailing whitespace from each current selection. It will not modify the file - it'll simply reduce the selection. Default shortcut is Ctrl+Alt+L.PKW4=/44Strip selection.pyimport sublime, sublimeplugin class stripSelectionCommand(sublimeplugin.TextCommand): """ Removes leading and trailing whitespace from selections """ def run(self, view, args): rs = [] for region in view.sel(): s = view.substr(region) if(not s.strip()): # strip whitespace selections rs.append(sublime.Region(region.begin(),region.begin())) continue a, b = region.a, region.b if(b > a): a += len(s) - len(s.lstrip()) b -= len(s) - len(s.rstrip()) else: # selection is inverted, keep it that way b += len(s) - len(s.lstrip()) a -= len(s) - len(s.rstrip()) rs.append(sublime.Region(a,b)) view.sel().clear() for region in rs: view.sel().add(region) def isEnabled(self, view, args): return view.hasNonEmptySelectionRegion(); PKW4=/PPDefault.sublime-keymapPKW4=) README.txtPKW4=/44Strip selection.pyPK