HomeComputer programmingCreating Basic Snippets in Sublime Text

Creating Basic Snippets in Sublime Text

By allowing you to create smart shortcuts when coding, snippets make coding less tedious.

Snippets are one of the coolest features in Sublime Text 2. Selecting from a library of predefined snippets of code makes life much easier when coding. Sublime has some snippets included by default, but you can easily create your own.

In this tutorial we will explore how snippets work and how you can create your own custom snippets.

1. Go to Tools -> New Snippet

Sublime Text Tools New Snippet

You will see a new file open with some skeleton XML in it

Sulbime Text Snippet 2

2. The content tags will hold what your snippet will print out. You would include your output within the the <![CDATA[ ]]> tag. For my example I put a simple HTML doctype as my snippet.

3

3. Next, we need to set a sequence of keys that will be bound to the snippet. In the tabTrigger tag, type what you want your sequence to be. I titled this one “doc2” for this example.

5

4. Go to File -> Save As to save your snippet. Now your ready to try it out.

5. When in a new document, type your trigger (‘doc2’ in our case) then hit the [tab] key.

6

7

Chris Luongo
Chris Luongo
Chris is a self-taught web designer and developer out of Atlanta, GA. This geek enjoys coffee, cold brews, bike riding, and twisting any form of tech into submission.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

LATEST REVIEWS

Recent Comments

error: Content is protected !!