VSCode 自动添加版权信息
操作步骤:
Ctrl + Shift + P
-> Preferences: Configure User Snippets -> New Global Snippets file...
输入任意名称回车后,自动生成如下模板:
{
// 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"
// }
}
比如我希望输入cpr之后直接输出如下内容,并且光标自动跳转到 description:
位置
/**
*@description:
*@author: Zijian TENG
*@date: 2021-03-11
*/
则应该这么修改:
{
"Print to console": {
"prefix": "cpr",
"body": [
"/**",
" *@description: $1", // 按一下 tab 自动跳转到这里
" *@author: Zijian TENG",
" *@date: ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}",
" */",
""
],
"description": "copyright snippets"
}
}
本文作者:Zijian/TENG(微信公众号:好记性如烂笔头),转载请注明原文链接:https://www.cnblogs.com/tengzijian/p/vscode-auto-complete-code-snippets.html