Skip to content

Instantly share code, notes, and snippets.

@qimingweng
Last active August 29, 2015 14:22
Show Gist options
  • Save qimingweng/5a00567fc568b35cdb81 to your computer and use it in GitHub Desktop.
Save qimingweng/5a00567fc568b35cdb81 to your computer and use it in GitHub Desktop.
A simple resource, for myself, for creating snippets in Sublime Text

A Guide to Snippets in Sublime Text

Snippet Structure

<snippet>
	<content><![CDATA[

This is the snippet body.
Use $1 to move the cursor here on a tab click
$2 is the second place the cursor goes
$3 is the third
${4:default content} here there is some default content.
$0 your cursor moves here after every thing else is done.

]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>newHtml</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<scope>text.html.basic</scope>
</snippet>

Different Scopes

source.js // Javascript
text.html // HTML

To check the scope of the file you are currently editing, hit ⌃⇧P, and the name of the scope will appear at the bottom left corner.

Syncing Snippets

I keep all my snippets in a folder in Dropbox, and I use a symlink to put that folder inside my ~/Library/Application Support/Sublime Text 3/Packages/User folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment