Sublime text 2 creates reusable code snippets

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.