VScode sets the user's own code snippet

VScode sets the user's own code snippet

In order to improve the speed and efficiency of writing code, we often use code snippets to "be lazy" when using vscode.

here is the image

insert image description here
There is a "User code snippet" option setting in the gear setting in the lower left corner of vscode, and there will be a search box after clicking

insert image description here
Among the many options, there is a file javascript.jsoncalled , which comes with vscode, click to open the json file

insert image description here
The contents inside will be displayed, and vscode will provide you with a chestnut, which is our commonly console.log()used code snippet. After I open the comment:

insert image description here

Everything in it is a json file, so a code snippet will be separated by a comma, so we have to follow its rules.

The first line: Print to consolemeans what to print out.
The second line: prefix: logmeans keywords ( that is, you only need to type the log in the js file to display the code hints )
. The third line: bodymeans the complete code displayed according to the keyword hints. (Include the newline symbol "\n", that is, an extra line will be automatically changed)insert image description here

tips:

1. Each line of the code content must be wrapped in English quotation marks: " ",

2. Since the code snippet is in JSON format, each line of code in the body must be separated by commas: ,

3. If you need to write quotation marks in special circumstances, it is recommended to use single quotation marks, because the first outermost layer is double quotation marks, if double quotation marks are used in the code, an error will be reported, so you can use single quotation marks: ' ',

4. Comments can also be written into code snippets, such as js comments, //just ,



that's all

Done, I wish you success.

Guess you like

Origin blog.csdn.net/Cavendixe/article/details/110949991