By josh / May 21, 2013

How to quickly add a new Sublime Text snippet

Reader Lucas C. recently converted from TextMate. He writes:

How am I supposed to quickly add a snippet in Sublime when I realize I need it, when I have to Google the XML syntax first? Also, why can’t I get a simple list of snippets that are defined for the current language? That all seems a bit magical to me.

The snippet syntax is hard to remember, but Sublime has a built-in template that does most of the work for you. Just select Tools | New Snippet from the application menu and you get a new tab with all the boilerplate XML, as well as an example that shows how to use basic placeholders.

You can also easily view a list of snippets available by typing snippet in the Command Palette. The snippets are filtered based on the current file syntax, so if you’re editing a Ruby file you won’t see PHP snippets.

Plugin of the Week

The [JavaScript Refactor plugin][] brings many of the conveniences of a full-fledged IDE to Sublime. You can double-click on a variable or function to jump to its definition, easily rename variables and functions, introduce variables, and extract blocks of code to create new methods.

How-To & Interesting Articles

Create new GitHub gists from Sublime

Running Sublime from Dropbox

Nice roundup of Sublime tips and plugins

P.S. Want to improve your mastery of Sublime Text? Start here:

About the author


Click here to add a comment

Leave a comment: