Sublime Text: Automating your tools
The snippet feature of Sublime Text allows you to avoid writing the same boilerplate code over and over again. For instance, on this blog, I write posts in MultiMarkdown and Jekyll compiles into HTML before posting.
This means that image links and code sections need to be appropriately flagged. That boilerplate is easy to make mistakes in so to avoid I wrote the following two snippets, with the help of this gist:
Snippet 1: R Code
This includes boilerplate formatting, auto-completion and exit points into the shortcut blog_r
+ TAB
.
Snippet 2: Image Links
This again includes consistent spacing and a position for the relative file name. The shortcut for this snippet is blog_img
+ TAB
and only applies to multimarkdown
files.
Summary
Snippets need the .sublime-snippet
extension to be recognized and need to be in the correct folder, but generating them through the Sublime Text interface handles the defaults gracefully.
The location is Tools>Developer>New Snippet...