Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import sublime
import sublime_plugin
class NumberCommand(sublime_plugin.TextCommand):
def run(self, edit):
selection = self.view.sel()
for region in selection:
value = int(self.view.substr(region))
self.view.replace(edit, region, str(self.op(value)))
except ValueError:
def is_enabled(self):
return len(self.view.sel()) > 0
class IncrementCommand(NumberCommand):
def op(self, value):
return value + 1
class DecrementCommand(NumberCommand):
def op(self, value):
return value - 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment