Skip to content

Instantly share code, notes, and snippets.

@takashi
Created November 5, 2015 05:42
Show Gist options
  • Select an option

  • Save takashi/69c0abc6597863f22cad to your computer and use it in GitHub Desktop.

Select an option

Save takashi/69c0abc6597863f22cad to your computer and use it in GitHub Desktop.
import sublime, sublime_plugin
class IncrementSelectionCommand(sublime_plugin.TextCommand):
def run(self, edit):
start_value = int(self.view.substr(self.view.sel()[0]))
counter = 0
for selection in self.view.sel():
self.view.insert(edit, selection.begin(), str(start_value + counter))
counter = counter + 1
for selection in self.view.sel():
self.view.erase(edit, selection)
class DecrementSelectionCommand(sublime_plugin.TextCommand):
def run(self, edit):
start_value = int(self.view.substr(self.view.sel()[0]))
counter = 0
for selection in self.view.sel():
self.view.insert(edit, selection.begin(), str(start_value + counter))
counter = counter - 1
for selection in self.view.sel():
self.view.erase(edit, selection)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment