Skip to content

Instantly share code, notes, and snippets.

@jdforsythe
Created August 11, 2015 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdforsythe/c1997e357c83cec16dd5 to your computer and use it in GitHub Desktop.
Save jdforsythe/c1997e357c83cec16dd5 to your computer and use it in GitHub Desktop.
Increment multiple selected numbers in SublimeText
import sublime, sublime_plugin
class IncrementNumbersCommand(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)
[
{ "keys": ["ctrl+shift+."], "command": "increment_numbers" }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment