添加代码片段:
settings --> user snippers --> new global snippers
官方示例:
1 | { |
2 | // Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and |
3 | // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope |
4 | // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is |
5 | // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: |
6 | // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. |
7 | // Placeholders with the same ids are connected. |
8 | // Example: |
9 | // "Print to console": { |
10 | // "scope": "javascript,typescript", |
11 | // "prefix": "log", |
12 | // "body": [ |
13 | // "console.log('$1');", |
14 | // "$2" |
15 | // ], |
16 | // "description": "Log output to console" |
17 | // } |
18 | } |
说明:
- scope: 需要应用的编程语言
- prefix: 触发代码
- body: 补全的内容,用
$1
等依次tab
选取。 - description: 显示的描述信息