在开发项目过程中经常需要设置设置头部注释,总是复制粘贴过于繁琐,我以python语言为例,各种语言都是相同设置方法。
打开编辑器的 文件->首选项->用户片段
弹出以下输入框,选择相应的语言.json
我选的python.json
{
// Place your snippets for python here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"HEADER": {
"prefix": "header",
"body": [
"#!/usr/bin/env python",
"# -*- encoding: utf-8 -*-",
"'''",
// "@文件 :$TM_FILENAME",
"@Description: :",
"@Date :$CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
"@Author :Javi",
"@version :1.0",
"'''",
// "",
// "$0"
],
},
}
“prefix:header” 是快捷代码的定义
“body”数组里就是定义的内容
设置完成后重启,在相应的语言文件里 输入 定义的 header