python配置
通過【文件→首選項→用戶代碼片段→選python】進入到 python.json修改的
python.json的具體內容如下:
{
"HEADER":{
"prefix": "qfr_header",
"body": [
"#!/usr/bin/env python",
"# -*- encoding: utf-8 -*-",
"'''",
"@File : $TM_FILENAME",
"@Time : $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
"@Author : qfr ",
"@Version : 1.0",
"@Contact : qfr@whu.edu.cn",
"@License : (C)Copyright 2021-2025, qfr&lz",
"@Desc : None",
"'''",
"",
"# here put the import lib",
"$0"
],
}
}
使用的時候,輸入:qfr_header即可。
C++配置
安裝插件KoroFileHeader
在vscode左下角點擊設置按鈕,選擇“設置”,然后輸入“fileheader”,
- 文件頭部注釋:Fileheader:custom Made
- 函數注釋:Fileheader:cursor Mode
隨便點擊哪個"在setting.json"中編輯,輸入以下設置后保存,然后重啟vscode更新設置
setting.json 內容如下:
{
"editor.suggestSelection": "first",
"python.defaultInterpreterPath": "D:\\Anaconda3\\envs\\pytorch\\python.exe",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"files.trimTrailingWhitespace": true
"workbench.colorCustomizations": {undefined
"editor.selectionHighlightBackground": "#288603",
"editor.selectionBackground":"#288603",
}
// 文件頭部注釋
"fileheader.customMade": {
"File" : "",
"Date" : "Do not edit",
"Author" : "qfr",
"Version" : "1.0",
"Contact" : "qfr@whu.edu.cn",
"License" : "(C)Copyright 2021-2025, qfr&lz",
"Desc" : "None"
},
//函數注釋
"fileheader.cursorMode": {
"name" :"",
"desc" :"",
"param" :"",
"return" :""
}
}
文件頭注釋:
crtl+win+i(window)
函數注釋:
crtl+win+t(window)
效果如下:

參考鏈接
VS Code 中配置新建 Python 文件自動添加頭部注釋
VS CODE 插件安裝:
