vs code custom code snippet

1. Shortcut Ctrl+Shift+P to open the command input snippet: (You can also click File => Preferences => User Code Snippets)

2. Select the code language type (here, take JavaScript as an example)

3. In the javascript.json file

prefix : This parameter is a shortcut entry for using the code segment. For example, the log here will have intellisense when inputting log in use.
body : This is the body of the code segment. The code that needs to be set is placed here, and the newlines between strings are separated by \r\n newlines. Note that if the value contains special characters, it needs to be escaped.
        Multi-line statements are separated by ,
$ 1           : This is the position of the cursor.
$ 2 : After using this parameter, the next position of the cursor will start a new line. Press the tab key to switch quickly, and you can also have $3, $4, $5 .....
description : The description of the code segment, the description when using IntelliSense

 4. Examples

5. Smart prompt effect

6. Actual code snippet output effect

 

Reference article address: https://www.cnblogs.com/summit7ca/p/5225494.html

       https://segmentfault.com/q/1010000011560076

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325259053&siteId=291194637