VScode配置代码自动保存,需要在settings.json
- 配置文件默认格式化器(
formatter) - 设置自动保存
配置默认格式化器
// 对所有的文件都生效
"editor.defaultFormatter": "esbenp.prettier-vscode",
也可单独配置一种文件,
// 比如typescript 对typescript文件格式化
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// 对vue文件生效
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
设置自动保存
"editor.formatOnSave": true,
我的settings.json 配置 2024/4/12
{
"editor.codeActionsOnSave": {},
"better-comments.tags": [
{
"tag": "!",
"color": "#FF2D00",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "?",
"color": "#3498DB",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "//",
"color": "#474747",
"strikethrough": true,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "todo",
"color": "#FF8C00",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "*",
"color": "#98C379",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
}
],
"tabnine.experimentalAutoImports": true,
"settingsSync.ignoredSettings": [],
"doxdocgen.generic.authorEmail": "andersonmingz@gmail.com",
"doxdocgen.generic.authorName": "mingongze",
"fileheader.configObj": {
"createFileTime": true,
"language": {
"languagetest": {
"head": "/$$",
"middle": " $ @",
"end": " $/",
"functionSymbol": {
"head": "/** ",
"middle": " * @",
"end": " */"
},
"functionParams": "js"
}
},
"autoAdd": true,
"autoAddLine": 100,
"autoAlready": true,
"annotationStr": {
"head": "/*",
"middle": " * @",
"end": " */",
"use": false
},
"headInsertLine": {
"php": 2,
"sh": 2
},
"beforeAnnotation": {
"文件后缀": "该文件后缀的头部注释之前添加某些内容"
},
"afterAnnotation": {
"文件后缀": "该文件后缀的头部注释之后添加某些内容"
},
"specialOptions": {
"特殊字段": "自定义比如LastEditTime/LastEditors"
},
"switch": {
"newlineAddAnnotation": true
},
"supportAutoLanguage": [],
"prohibitAutoAdd": ["json"],
"folderBlacklist": ["node_modules", "文件夹禁止自动添加头部注释"],
"prohibitItemAutoAdd": [
"项目的全称, 整个项目禁止自动添加头部注释, 可以使用快捷键添加"
],
"moveCursor": true,
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"atSymbol": ["@", "@"],
"atSymbolObj": {
"文件后缀": ["头部注释@符号", "函数注释@符号"]
},
"colon": [": ", ": "],
"colonObj": {
"文件后缀": ["头部注释冒号", "函数注释冒号"]
},
"filePathColon": "路径分隔符替换",
"showErrorMessage": false,
"writeLog": false,
"wideSame": false,
"wideNum": 13,
"functionWideNum": 0,
"CheckFileChange": false,
"createHeader": false,
"useWorker": false,
"designAddHead": false,
"headDesignName": "random",
"headDesign": false,
"cursorModeInternalAll": {},
"openFunctionParamsCheck": true,
"functionParamsShape": ["{", "}"],
"functionBlankSpaceAll": {},
"functionTypeSymbol": "*",
"typeParamOrder": "type param",
"customHasHeadEnd": {},
"throttleTime": 60000,
"functionParamAddStr": "",
"NoMatchParams": "no show param"
},
"fileheader.customMade": {
"Date": "Do not edit", // 文件创建时间(不变)
// 文件最后编辑者
"LastEditors": "mingongze (andersonmingz@gmail.com)", // "git config user.name && git config user.email",
"LastEditTime": "Do not edit", // 文件最后编辑时间
"FilePath": "Do not edit" // 文件在项目中的相对路径 自动更新
},
"Codegeex.Privacy": true,
"workbench.sideBar.location": "right",
"files.autoSave": "afterDelay",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"workbench.colorCustomizations": {},
"prettier.semi": false,
"prettier.singleQuote": true,
"prettier.arrowParens": "avoid"
}