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 vscode customizes user code snippets

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Editor to share with you how to customize vscode user code snippet, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The methods are as follows:

First, open VS code, "File-preferences-user Code snippet" (file-preference-User Snippets), select the html file in the drop-down list, and automatically create a new file called html.json in the application data folder of VS code, in which we define our code snippet.

We need to define snippet name first. In snippet name, prefix and body are two essential fields (The prefix is what is used to trigger the snippet and the body will be expanded and inserted.)

We define a html framework, named html template, with the following code:

Save, create a new html file, enter html template, press the Tab key, you can automatically complete the entire frame.

Syntax description:

In body, use the escape character\ to write tabs such as Tab, double quotes, etc.

Use ${num: default name} to define the input location, press the Tab key to advance the cursor to the next

The value of num is 0Pert 1, 2pm 3... 0 is the final position of the cursor, 1, 1, 2, 2, 3. Determines the sequential position of the cursor

Default name is the default value, you can press Tab to skip it without editing.

Global or Specific Snippets

There are two types of code snippets: global and specific, which means that we can define code snippets that apply to multiple file types, or we can define code snippets that apply to only one file type.

The file suffix for the global snippet is .code-snippets, and at the top of the user snippet drop-down list is a "New Global snippet File".

The syntax rules of a global code snippet are the same as those of a specific code snippet, except that it adds a field, scope, to specify which language the rule applies to:

The above is all the content of the article "how to customize user code snippets in vscode". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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