vscode 使用文件模板功能来添加版权信息

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 文件自动在文件最上方添加预设信息

相关推荐
XZHOUMIN2 小时前
网易博客旧文-----XCODE离线帮助文件使用的补充说明
ide·macos·xcode
爱吃土豆的马铃薯ㅤㅤㅤㅤㅤㅤㅤㅤㅤ3 小时前
idea 删除本地分支后,弹窗 delete tracked brank
java·ide·intellij-idea
言慢行善3 小时前
idea出现的问题
java·ide·intellij-idea
csucoderlee4 小时前
eclipse mat leak suspects report和 component report的区别
java·ide·eclipse
bjxiaxueliang4 小时前
一文详解MacOS使用VSCode搭建SpringBoot+Gradle开发环境
spring boot·vscode·macos
想取一个与众不同的名字好难6 小时前
android studio导入OpenCv并改造成.kts版本
android·ide·android studio
Best_Me076 小时前
如何在Pycharm的终端里进入自己的环境
ide·python·pycharm
HelloMagina7 小时前
Xcode控制台“po“错误:表达式解析失败
ide·macos·xcode
ahadee7 小时前
蓝桥杯每日真题 - 第12天
c++·vscode·算法·蓝桥杯
vortex57 小时前
解决 VSCode 中 C/C++ 编码乱码问题的两种方法
c语言·c++·vscode