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.
Creating First Snippet
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.
Package Control Snippets
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 −
- EverCodeLab Sublime supports for Ruby on Rails
- Additional PHP snippets for PHP
- HTML snippets for HTML files
- Twitter Bootstrap snippets for Twitter Bootstrap
- jQuery snippets pack for jQuery
Table of Contents
1.sublime text tutorial
2.sublime text introduction
3.sublime text installation
4.sublime text data directory
5.sublime text creating first document
6.sublime text editing first text document
7.sublime text patterns of code editing
8.sublime text sublime linter
9.sublime text shortcuts
10.sublime text snippets
11.sublime text macros
12.sublime text key bindings
13.sublime text column selection
14.sublime text indentation
15.sublime text base settings
16.sublime text theme management
17.sublime text understanding vintage mode
18.sublime text vintage commands
20.sublime text testing python code
21.sublime text spell check
22.sublime text packages
23.sublime text menus
24.sublime text sub menus of font
25.sublime text developing plugin
26.sublime text command palette
27.sublime text debugging php application
29.sublime text batch processing
30.sublime text distraction free mode
31.sublime text sublimecodeintel plugin
32.sublime text quick guide
33.sublime text useful resources
34.discuss sublime text