一、结合插件koroFileHeader
- 安装koroFileHeader插件到vscode。
- FIle(文件)=>Preferences(首选项)=>settings(设置),在workspace下查到File header Config,打开其中一个进行编辑(也可以ctrl + shift + p,搜索preferences :open settings)
添加代码块,快捷键:window:ctrl
+win
+i
mac:ctrl
+cmd
+i
linux:ctrl
+meta
+i
Ubuntu:ctrl
+super
+i
"fileheader.customMade": {
// 头部注释默认字段
"Author": "***",
"Date": "", // 设置后默认设置文件生成时间
"LastEditTime": "", // 设置后,保存文件更改默认更新最后编辑时间
"LastEditors": "***", // 设置后,保存文件更改默认更新最后编辑人
"Description": "",
"FilePath": "", // 设置后,默认生成文件相对于项目的路径
"custom_string_obkoro1": "加油搞起来"
},
键入快捷键,稍等一下(根据网络快慢)
添加代码块,快捷键:window:ctrl+win+t mac:ctrl+cmd+t linux: ctrl+meta+t Ubuntu: ctrl+super+t
"fileheader.cursorMode": {
// 默认字段
"description":"",
"param":"",
"return":""
}
二、添加代码块,FIle(文件)=>Preferences(首选项)=>configure user snippets(用户代码块),选择javascript.json,修改添加
{
"Print to zhushi": {
"prefix": "zhushi",
"body": [
"<!--",
"* @Description: $0",
"* @Author: your name",
"* @Date: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
"* @LastEditTime: $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
"* @LastEditors: Please set LastEditors",
"-->"
],
"description": "a zhushi mode"
},
"Print to func": {
"prefix": "func",
"body": [
"/**",
" * @func $1",
" * @Description $2",
" * @Author: your name",
" * @param {$3} $4 $5",
" * @return {$6} $7",
" */"
],
"description": "a func mode"
},
"Print explain": {
"prefix": "explain",
"body": [
"/**",
" * @description",
" * @param {*}",
" * @public",
" */ ",
],
"description": "Log output to console"
}
}
此时在相应位置键入zhushi 、func、explain就能得到相应提示,追加注释代码