Understanding your first snippet
We learned that snippets can be very helpful, so how about creating our own? We'll make an awesome HTML snippet, better than the one in the preceding example. First, let's have a look at how snippets work in more detail.
How do snippets work?
Snippets can be saved under any package folder, but we'll start with saving our snippets under Packages/User
. Snippets must live in a Sublime package.
File format and syntax
Snippets are simple XML-formatted files with the extension sublime-snippet
. The root XML tag will always be <snippet>
and will then contain the following:
Content
: This tag represents the actual snippet.If we want to write
$
, we'll need to escape it with\$
.For indentation, use tabs only. If the
translate_tabs_to_spaces
option is set totrue
, tabs will be transformed to spaces automatically when the snippet is inserted.The
Content
tag must contain the<![CDATA[…]]>
section. Snippets won't work if we won't do it.Also, the
Content
tag cannot...