一、snippets
snippets 主要用于在进行文件及函数进行注释说明时,一键生成自定义格式注释 使用。
1.1 点击 vscode 设置,选择 User Snippets
1.2 编辑 code-snippets 文件
以C++ 文件注释为例,文件作用注释 fun_cpp_file.code-snippets
,内容如下:
- “prefix”: “///” : prefix 表示使用
//
驱动文件一键注释 - “body”: [xxx] : body 中的内容是要自定义生成的注释格式
{"Print to console": {"prefix": "///", //这里是快捷键方法"body": [" Filename: ${TM_FILENAME}"," Version: \"1.0\""," Author: ZYG "," Date: ${CURRENT_YEAR}/${CURRENT_MONTH}/${CURRENT_DATE}",// " LastEditor: ZYG ",// " LastEditTime: ${CURRENT_YEAR}/${CURRENT_MONTH}/${CURRENT_DATE} "," Description: ","*/"],"description": "Log output to console"}
}
函数作用注释 fun_cpp.code-snippets
,内容格式如下:
{"Print to console": {"prefix": "/.", //这里是快捷键方法"body": ["/**"," * @description: //TODO"," * @date: ${CURRENT_YEAR}/${CURRENT_MONTH}/${CURRENT_DATE}"," * @author: ZYG "," * @param: "," * @return: ","**/"],"description": "Log output to console"}
}
1.3 验证
完成以上操作,打开任意一cpp文件, 按键输入 /
, 会出现如下弹窗:
图中前两个选项即是 步骤1.2 生成的注释模板,方向键选择后,回车确定,即可出现自定义的格式效果。
二、Todo Tree
2.1 安装 todo tree 插件
2.2 配置 setting.json
2.2.1 打开setting.json 方法一
2.2.1.1 点击左下角设置按钮
2.2.1.2 在搜索框输入:settings.json, 并选中
2.2.2 打开setting.json 方法二
2.2.2.1 点击左下角设置按钮点击设置
2.2.2.2 出现如下界面,点击文本编辑器,慢慢往下滑动找到settings.json,点击即可。
2.2.3 编辑setting.json 文件
{"editor.minimap.enabled": false,"editor.mouseWheelZoom": true,"hediet.vscode-drawio.resizeImages": null,"hediet.vscode-drawio.customColorSchemes": [],"hediet.vscode-drawio.theme": "atlas","window.zoomLevel": 1,"extensions.ignoreRecommendations": true,"cmake.showOptionsMovedNotification": false,"editor.codeActionsOnSave": {},"doxdocgen.generic.paramTemplate": "@param[in] {param} ","todo-tree.highlights.defaultHighlight": {"icon": "alert","type": "text","foreground": "red","iconColour": "green"},"todo-tree.general.tags": ["?","!"," Step ","YARD"],"todo-tree.highlights.customHighlight": {" Step ": {"foreground": "#7CFC00","icon": "question","iconColour": "green","type": "text-and-comment","hideFromTree": true},"?": {"foreground": "yellow","icon": "question","iconColour": "yellow","type": "text-and-comment"},"!": {"foreground": "red","icon": "issue-opened","iconColour": "red","type": "text-and-comment"},"YARD": {"foreground": "#5361dd","icon": "author","iconColour": "blue","type": "text-and-comment"},},"todo-tree.general.revealBehaviour": "highlight todo","todo-tree.tree.showCountsInTree": true,"todo-tree.filtering.excludeGlobs":["**/*.txt","**/*.md"]
}
- 重点关注点1: “todo-tree.general.tags”: [ xxxxx],
- 重点关注点2: " Step ": { xxxx},
- 留意 各处
,
的位置
2.3 验证
保存后, 以// Step
格式添加注释,此时会发现该注释高亮如下图所示: