Snippets are the smart templates which can be reused whenever needed. Sublime text editor includes snippets feature for HTML templates. In this chapter, you will learn about them in detail.
Snippets are simple XML supported files with various attributes. They include an extension called sublime-snippet. The root tag of XML element will be the <snippet> tag. Snippets created are saved in the Packages folder and are considered to live in this folder.
The file format and syntax of snippets are discussed in detail as follows −
Content −This section includes description of the snippet.
tabTrigger − It includes a sequence of characters which trigger when the snippet is written.
Scope − It defines the scope in which the snippet remains active.
Description − It includes all the meta description. It will be displayed when snippet’s menu is open.
You can create the default snippet using Tools → Developer → Snippet option.
Then, a demo snippet with the associated tags will be created as shown below −
To create a first snippet in Sublime Text editor, click the Tools menu and select the Snippets option from the drop down window, as shown in the screenshot here.
Now, choose Snippet:html from the options displayed.
This creates a default snippet on the specified html file as shown below.
Note that there are various snippets for different types of files. For html files in the code base, there are three snippets defined in Sublime Text editor, as shown below.
Control snippets are primarily used for product development. With install packages option in Sublime editor, you can download any snippet needed for web development and install it.
You may need the following packages for web development −