vscode quickly add snippet

Before writing html in vscode, only you need to enter a , press Enter or tab you can generate some html code.
Vue in the learning process, the input template vue each time, as in FIG.
Here Insert Picture Description

Vue paper to create templates, for example, shows a method to quickly add the code snippet.


  1. shift + ctrl (command) + p, open the search bar, enter snippets (English meaning fragments), found Preferences: Configure User Snippets
    Here Insert Picture Description

  2. Enter html, open html.json (if you need to add C ++ fragment, you can open cpp.json)
    Here Insert Picture Description

  3. html.jsonSample code given segment. Rigorous sake, copy and paste this sample, and uncomment.
    Here Insert Picture Description

  4. Modify information:
    name of the first segment of the behavior of the code, just change all right, I defined my vue html code.
    The second line is a custom prefix generate key codes, I defined as log
    the third line of body, add your code within the brackets.

"my vue html code": {
  "prefix": "vue",
  "body": [
    
  ],
  "description": "Log output to console"
}

Here Insert Picture Description

Note here that the code needs to be added each row with a double in quotation marks.
vscode select multiple lines of approach: windows alt + click with the mouse; mac with option + mouse click.
Selected after the multi-line double quotes may be added together to the line head and line end of each row.
Finally, remember that each row with a comma.

Here Insert Picture Description

For html, also need to double the original quote quote all into a single
method is still the alt + mouse click, select Modify together after all need to change positions.
Here Insert Picture Description

After completion, the direct input in the html code segment where needed the prefix keyword, can automatically generate a code segment.

Published 673 original articles · won praise 644 · views 380 000 +

Guess you like

Origin blog.csdn.net/zhaohaibo_/article/details/104367573