Sublime Text Multiple Command Shortcut
On my team at work, many of us use the Sublime Text editor. I use two packages to keep my code clean - JsFormat and AmdButler. These are great, but it’s a pain to run them separately. Why not run them both with a single keyboard shortcut?! Here’s how to do that.
After you have both packages installed, go to “Tools > New Plugin”. Use this for your new plugin:
import sublime, sublime_plugin
class SortAndJsFormatCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command("amd_butler_sort")
self.view.run_command("js_format")
Sublime Text automatically exposes a “command” by taking the camel-cased name of your python class, replaced with underscores, and removing the word “Command”. So the command name is “sort_and_js_format”. You can now use this if you go to “Preferences > Key Bindings - User” -
{"keys": ["ctrl+alt+s"], "command": "sort_and_js_format"}
(Thanks to this StackExchange answer for help)
Subscribe
Get an email summary of my blog posts (four per year):
... or follow the blog here: