Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create Custom Code snippets in sublime

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to create a custom code segment in sublime, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.

To create a custom code snippet in sublime

1. Generate the basic skeleton

After opening sublime, create a new file and make sure that the file type in the lower right corner is changed from the default Plain Text to HTML. And then use it! Or html:5 with Tab key to quickly generate the default basic skeleton code snippet.

2. Edit the custom code snippet

The keyword $is used in the entry function of jquery. Because $is a syntax keyword of the code snippet, if you use "$" directly in the custom code snippet, a syntax error will occur and the code snippet cannot be generated. You can choose to use "$" instead of "$" in the code snippet. Later, when you use keyboard shortcuts to generate code snippets, the escape symbol "\" does not appear.

3. Set parameters and save the custom code snippet

Select Tools- > Developer- > New Snippet in the menu bar. A new interface in XML format is generated, as shown below.

Hello, ${1:this} is a ${2:snippet}.

This section is just to prompt us to set and control the syntax of the cursor pause position in the code snippet. After you write it down, you can delete this line of code, and then copy and paste the custom code snippet we just edited. (insert in the position of line 3, as shown in the following figure).

We can control the position of the cursor in the generated code snippet according to the syntax prompted earlier, which is more convenient for later editing.

If we modify the original code snippet to.

${1:01}-jquery case-${2:} ${3:}

Indicates that after the code snippet is created and quickly generated with keyboard shortcuts, the customs mark first appears in front of 01, and select the 01 field to facilitate modification and editing. Then press the Tab key, and the cursor appears after the jquery-, where there is no selected content to facilitate the insertion of content. Press the Tab key again, and the cursor will appear in the tag pair of body, where it is also convenient to insert content.

After that, remove the comment and enter the name of the custom shortcut command in the label pair. As shown below.

After that, we type myjquery in the newly created HTML file, and then type Tab to quickly generate our custom code snippet.

When you are finished editing, save. Save it directly with ctri+s to Packages- > User in sublime's installation directory by default. In order to facilitate the management of our custom code snippets, create a new snippets folder and save the custom code snippet files to this folder.

The file name can be customized, but the suffix name must be. Sublime-snippet, otherwise an error will occur.

This completes the creation of custom code snippets, and then create a new HTML file in sublime, then enter myjquery, and then cooperate with the Tab key to quickly generate the specified custom code snippets!

Thank you for reading this article carefully. I hope the article "how to create custom code snippets in sublime" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report