Sublime Text 2 Snippets

The other day I stumbled across an amazing feature of Sublime Text 2 that doesn't require a plugin to work, yet somehow after 1 year of using the software I hadn't come across it. If you ever find yourself rewriting huge code blocks such as configs, or copying/pasting lots of text and replacing certain parts for folder names for example then Snippets are the perfect tool! This is a short post to share awareness of this awesome feature.

The Snippets Documentation is very simple to follow and writing your own couldn't be easier. How I have survived this long without this tool is crazy, they speed up productivity so much when programming. This feature should be emphasised more as it adds so much functionality right out of the box which is normally only obtained via the package system. Quote from the documentation "Snippets can be stored under any package’s folder, but to keep it simple while you’re learning, you can save them to your Packages/User folder". This means it's very simple to get started in writing them with no previous setup. I am tempted to write a plugin to manage snippets and share them better, but something makes me think one may already exist so I'll do some research into that.

The quickest way to get started with snippets is to go to "Tools -> New Snippet" from inside the Sublime Text 2 menu system. I find it ironic how there isn't a keyboard shortcut for that. From here you can start writing the content for your snippet which can be as simple as copy/paste text block (I have one for standard HTML5 with bootstrap layout) or a more advanced template such as what I use for Nginx Configs during development. I'm going to be sharing a lot more of these via the Github Gist system over the new few weeks because they have helped me so much!

Feel free to share your own or others in the comments or use mine as you please.