简体   繁体   中英

How to add customized tags quickly in Sublime text 2?

Sorry for the newbie question. I'm using multiple times of the same tag with the same class, for example:

<p class = "paragraph_1"></p>

I'm just wondering how to add this same tag quickly in Sublime Text 2? I know the default tags can be added quickly by just typing a part of them and hit Tab . Is there any similar convenient way for those tags customized by myself?

Thank you very much!

The Sublime Text HTML package inserts snippets into the completion system. If you also want to have your tags, you can just write a snippet for each tag.

To create a snippet:

  1. Open your User directory
    1. Click on Preferences
    2. then on Browse Packages...
    3. Open the directory User
  2. Create a file snippet_name.sublime-snippet
  3. Paste this into your snippet and change the content as you want:
<snippet>
  <!-- Example: Hello, ${1:this} is a ${2:snippet}. -->
  <content><![CDATA[
<p class="paragraph_1">$0</p>
]]></content>
  <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
  <tabTrigger>par1</tabTrigger>
  <description>Tag</description>
  <!-- Optional: Set a scope to limit where the snippet will trigger -->
  <scope>text.html.basic</scope>
</snippet>

However using SnippetMaker you can easily shorten the process. Just select the content, press ctrl+shift+p and write SnippetMaker: Make Snippet .

Additional remarks:

  • You can remove the snippet by removing the file.
  • The position of $0 marks cursor position at the end of the snippet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM