设置vscode格式化代码配置,不过不会保存是自动格式化需要 shift+alt+f 格式化,这个文章只是配置格式化时按两格缩进,双引号变单引号,不强行换行等功能,我用着是挺顺的,分享给大家
1 下载插件 2 删除插件 3 找到设置中的 4 将下面代码复制进去保存
{
"files.associations": {
"*.cjson": "jsonc",
"*.wxss": "css",
"*.wxs": "javascript",
"*.js": "javascript"
},
"emmet.includeLanguages": {
"wxml": "html"
},
"minapp-vscode.disableAutoConfig": true,
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"javascript": {
"indent_size": 2
},
"css": {
"indent_size": 2
},
"html": {
"indent_size": 2
},
"editor.codeActionsOnSave": null,
"editor.detectIndentation": false,
"editor.tabSize": 2,
"eslint.autoFixOnSave": true,
"prettier.eslintIntegration": true,
"prettier.semi": false,
"prettier.singleQuote": true,
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"vetur.format.defaultFormatter.html": "js-beautify-html",
"vetur.format.defaultFormatter.js": "vscode-typescript",
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_line_length": 0,
"wrap_attributes": "auto",
"end_with_newline": false
},
},
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "html",
"autoFix": true
},
{
"language": "vue",
"autoFix": true
}
],
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/dist": true
},
"window.title": "${dirty}${activeEditorMedium}${separator}${rootName}",
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"diffEditor.wordWrap": "on",
"editor.fontWeight": null,
}
最后重启vscode
|