In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the method of creating custom code snippets for vscode. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Here's an example of creating a javascript snippet:
1. You can first open a javascript file (or in the current open file) and press the shortcut key Ctrl+Shift+P to open the command to enter snippet: (you can also click File = > preferences = > user code snippet)
2. After selecting the option, a list of languages appears to select which language to create code snippets for. Here, take setting up the Console.WriteLine snippet of javascript as an example, the method is the same in other languages.
When javascript is selected, a configuration file in JSON format is automatically opened.
{/ / Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and / / description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: / / $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the / / same ids are connected. / / Example: / / "Print to console": {/ / "prefix": "log", / / "body": [/ / "console.log ('$1') ", / /" $2 "/], / /" description ":" Log output to console "/ /},}
Modify the contents according to your own needs as follows:
{/ / Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and / / description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: / / $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the / / same ids are connected. / / Example: "Page Header": {"prefix": "ducx", "body": ["/ * *", "* $1", "*", "* @ author ducx" "* @ created $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND", "* /", "$2"], "description": "page header"}}
After saving, open a js file, enter the prefix ducx and enter enter after the shortcut prompt window appears. At this time, our custom code snippet structure has been generated, and press tab in turn.
/ * * @ author ducx * @ created 17:08:37 on 2018-08-31 * / this is the end of this article on "vscode's method for creating custom code snippets". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.