Key bindings are pretty great, and I rely on them all the time. So it's lucky for me that sublime allows for adding custom key bindings - and they're pretty easy to add.
One key binding I have is to add an image tag (with `src`, `srcset`, and `alt` attributes). So how do we add that? On a Macbook, we click on the main "Sublime Text" menu item, then under the "Preferences" submenu we select "Key Bindings". It's a JSON file, with an array of key binding objects. There's a couple of properties each need:
- keys: the sequence of keys we need to press to add our snippet (and as an aside, "super" is in reference to the command key)
- command: what the key binding will do (for us, it's "insert_snippet" - there are others but for us for the time being, this is all we need to know)
- args: this is an object that will contain the markup we will insert (under the nested property `contents`)
Alright, here's a snippet of what the entire key bindings file would like like with just that one key binding:
[gist src=https://gist.github.com/benrgreene/237bba7ee4b46a85ad6cecf2719f0dd5 file=key-bindings.json][/gist]