For front-end engineers, the basic structure of writing an HTML page is physical activity. It is also troublesome to copy one page each time. sublime text 2 provides a good way to reuse code snippets. The following describes how to create an HTML5 code snippet.
Click Tools> New snippet on the menu to create an XML file tab:
1 <snippet>2 <content><![CDATA[3 Hello, ${1:this} is a ${2:snippet}.4 ]]></content>5 <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->6 <!-- <tabTrigger>hello</tabTrigger> -->7 <!-- Optional: Set a scope to limit where the snippet will trigger -->8 <!-- <scope>source.python</scope> -->9 </snippet>
The comments have already been described in more detail.
The content contains the Code Template: $ {serial number: Default Value}. The cursor stops at the place where the serial number is the same and can be edited at the same time. The size of the sequence number is tabindex. When using the code, you can use tab to switch the cursor position.
Tabtrigger indicates that after the string is input, Tab inserts content in the content with the cursor.
Scope refers to the file type used.
The following is the definition of HTML5 code snippets:
1 <snippet> 2 <content><![CDATA[ 3 <!doctype html> 4
After editing, save it as the default save path of c: \ Users \ [user] \ appdata \ roaming \ sublime text 2 \ packages \ User \ html5.sublime-snippet (under win7. The suffix must be. sublime-snippet.
After saving and restarting sublime text 2, create a file: Enter HTML5, And the tab will show the following effect:
$ {1} appears twice, so the cursor is edited at the same time.
$ {2: This}, so the default value of this appears at 2. After you finish editing $ {1}, press tab to ${2.
OK, that's all.