This guide is deprecated. New content at docs.sublimetext.info
Sublime Text snippets are generally compatible with Textmate snippets.
Snippet files are XML files with the sublime-snippet extension.
<snippet>
<content><![CDATA[]]></content>
<tabTrigger></tabTrigger>
<scope></scope>
<description></description>
</snippet>
$PARAM1 .. $PARAMn | Arguments passed to the insertSnippet command. |
$SELECTION | The text that was selected when the snippet was triggered. |
$TM_CURRENT_LINE | Content of the line the cursor was in when the snippet was triggered. |
$TM_CURRENT_WORD | Current word under the cursor when the snippet was triggered. |
$TM_FILENAME | File name of the file being edited including extension. |
$TM_FILEPATH | File path to the file being edited. |
$TM_FULLNAME | User’s user name. |
$TM_LINE_INDEX | Column the snippet is being inserted at, 0 based. |
$TM_LINE_NUMBER | Row the snippet is being inserted at, 1 based. |
$TM_SELECTED_TEXT | An alias for $SELECTION. |
$TM_SOFT_TABS | YES if translateTabsToSpaces is true, otherwise NO. |
$TM_TAB_SIZE | Spaces per-tab (controlled by the tabSize option). |
Mark positions to cycle through by pressing TAB or SHIFT + TAB.
Syntax: $1 .. $n
Fields with the same name mirror each other.
Fields with a default value.
Syntax: ${1:PLACE_HOLDER} .. ${n:PLACE_HOLDER}
Fields and place holders can be combined and nested within other place holders.
Syntax:
- ${var_name/regex/format_string/}
- ${var_name/regex/format_string/options}