安装Vscode插件
设置Vscode
- 勾选下图两个对钩
- settings.json 替换为下面Json
{
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"git.confirmSync": false,
"prettier.trailingComma": "none",
"prettier.printWidth": 500,
"files.associations": {},
"editor.tokenColorCustomizations": {
"comments": "#32CD32" // 注释颜色
},
"editor.tabCompletion": "onlySnippets",
"timeline.excludeSources": [
"git-history"
],
"html.format.contentUnformatted": "",
"editor.formatOnPaste": true,
"path-intellisense.mappings": {},
"eslint.enable": true,
"eslint.autoFixOnSave": true,
"eslint.options": {
"extensions": [
".js",
".vue"
]
},
"eslint.validate": [ //验证
"javascript",
"javascriptreact",
// "html",
// "vue",
{
"language": "html",
"autoFix": true
},
{
"language": "vue",
"autoFix": true
}
],
// https://www.cnblogs.com/cbpm-wuhq/p/12558519.html
// 每次保存的时候将代码按eslint格式进行修复
"eslint.autoFixOnSave": true,
// "editor.tabSize": 2,
// 点击保存时,根据 eslint 规则自定修复,同时集成 prettier 到 eslint 中,让prettier使用eslint的代码格式进行校验
"prettier.eslintIntegration": true,
"prettier.singleQuote": true, //使用单引号替代双引号
// "javascript.format.insertSpaceBeforeFunctionParenthesis": false, //让函数(名)和后面的括号之间加个空格
"vetur.format.defaultFormatter.html": "js-beautify-html", //格式化.vue中html
"vetur.format.defaultFormatter.js": "vscode-typescript", //让vue中的js按编辑器自带的ts格式进行格式化
// "vetur.format.defaultFormatterOptions": {
// "js-beautify-html": {
// "wrap_attributes": "force-aligned" //属性强制折行对齐
// }
// },
"editor.largeFileOptimizations": false,
"explorer.confirmDragAndDrop": false,
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"explorer.confirmDelete": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"gitlens.gitCommands.closeOnFocusOut": true,
"eslint.codeAction.disableRuleComment": {},
"[less]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"git.suggestSmartCommit": false,
"editor.fontLigatures": null,
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_attributes": "force-aligned" //属性强制折行对齐
},
"prettyhtml": {
"printWidth": 5,
"singleQuote": false,
"wrapAttributes": false,
"sortAttributes": false
},
"prettier": {
"semi": true, //去掉代码结尾的分号
"singleQuote": false //使用单引号替代双引号
}
},
"vue-format.break_attr_limit": 1,
"vue-format.format_need": [
"pcss",
"auto",
"[javascript]",
"[less]",
"[vue]",
".vue",
"html",
"js",
"css"
],
"vue-format.html_indent_root": true,
"liveServer.settings.donotShowInfoMsg": true,
"gitTreeCompare.diffMode": "full",
"workbench.startupEditor": "newUntitledFile",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"workbench.editor.enablePreview": false,
"vue-format.js-beautify": {
"indent_size": "editor.tabSize",
"indent_char": " ",
"indent_with_tabs": false,
"brace-style": "collapse",
"space_after_anon_function": true,
"css": {},
"js": {},
"html": {
"force_format": [
"template"
]
}
},
"vetur.ignoreProjectWarning": true,
"vetur.format.options.tabSize": 4,
"gitlens.views.searchAndCompare.avatars": false,
"[css]": {
"editor.defaultFormatter": "HookyQR.beautify"
},
"liveServer.settings.donotVerifyTags": true,
"[jsonc]": {
"editor.defaultFormatter": "HookyQR.beautify"
},
"terminal.integrated.tabs.enabled": true,
//"workbench.colorTheme": "Monokai",
"workbench.editorAssociations": {
"*.png": "luna.editor"
},
"gitlens.views.repositories.avatars": false,
"git.autofetch": true,
"security.workspace.trust.untrustedFiles": "open",
"markdown-preview-enhanced.previewTheme": "medium.css",
"C_Cpp.updateChannel": "Insiders",
"window.zoomLevel": 2,
"cmake.configureOnOpen": true,
"workbench.iconTheme": "material-icon-theme",
"editor.formatOnSave": true
}