- 打开vscode>文件>首选项>用户代码片段>新建json文件
- 或者按ctrl +shift + p 输入 snippet 新建
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. 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": {
"scope": "javascript,typescript",
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
},
"for of ": {
"scope": "javascript,typescript",
"prefix": "fof",
"body": [
"for(let item of $1){"
,"\t$2"
,"}"
],
"description": "快速循环数组"
}
}
(注意:创建哪种语言的代码片段就进相应语言的代码片段区域,写js代码段就不要把代码段写在了php的代码段编写区)
\r\n:代表换行,填写几个代表换几行,
\t:tab数,有几个代表有几个tab
网友评论