vscode 新建文件的时候,自动填充作者及版权信息
无需使用插件,操作如下:
- 选择 "首选项(Preferences)"。
- 在搜索框中输入 "file template" 或者 "文件模板",然后选择相关的设置项。
bash
{
"C_Cpp.clang_format_fallbackStyle": "none",
"C_Cpp.clang_format_path": "/usr/local/bin/clang-format",
"editor.detectIndentation": false,
"editor.renderWhitespace": "all",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"psi-header.templates": [
{
"language": "shellscript",
"template": [
" Copyright <<year>>. All Rights Reserved.",
" Author: Weida Lei (livedia@qq.com)",
""
]
},
{
"language": "java",
"template": [
" Copyright <<year>>. All Rights Reserved.",
" Author: Weida Lei (livedia@qq.com)",
""
]
},
{
"language": "scala",
"template": [
" Copyright <<year>>. All Rights Reserved.",
" Author: Weida Lei (livedia@qq.com)",
""
]
},
{
"language": "python",
"template": [
" Copyright <<year>>. All Rights Reserved.",
" Author: Weida Lei (livedia@qq.com)",
""
]
},
{
"language": "cpp",
"template": [
" Copyright <<year>>. All Rights Reserved.",
" Author: Weida Lei (livedia@qq.com)",
""
]
},
{
"language": "proto3",
"template": [
" Copyright <<year>>. All Rights Reserved.",
" Author: Weida Lei (livedia@qq.com)",
""
]
},
{
"language": "starlark",
"template": [
" Copyright <<year>>. All Rights Reserved.",
" Author: Weida Lei (livedia@qq.com)",
""
]
}
],
"psi-header.changes-tracking": {
"autoHeader": "manualSave"
},
"psi-header.lang-config": [
{
"language": "shellscript",
"begin": "",
"end": "",
"prefix": "#"
},
{
"language": "python",
"begin": "",
"end": "",
"prefix": "#"
},
{
"language": "starlark",
"begin": "",
"end": "",
"prefix": "#"
},
{
"language": "proto3",
"begin": "",
"end": "",
"prefix": "//"
},
{
"language": "cpp",
"begin": "",
"end": "",
"prefix": "//"
},
{
"language": "java",
"begin": "",
"end": "",
"prefix": "//"
},
{
"language": "scala",
"begin": "",
"end": "",
"prefix": "//"
}
],
"git.ignoreLegacyWarning": true,
"workbench.editor.closeEmptyGroups": false,
"[cpp]": {
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
},
"C_Cpp.intelliSenseEngine": "Disabled",
"clangd.detectExtensionConflicts": false,
"cmake.configureOnOpen": true,
"editor.formatOnSave": true,
"editor.tabSize": 2,
"editor.fontSize": 13,
"editor.minimap.enabled": false,
"window.zoomLevel": 1,
"doxdocgen.file.copyrightTag": [],
}
可以针对不同文件设置不同的信息
示例:
新建 test.h 文件
test.h 文件自动在文件最上方添加预设信息