Visual Studio Code 保存文件时自动格式化当前页代码
使用到的插件
- Beautify:用于对html css js等文件代码格式化。
- Vetur:用于对Vue代码格式化,也可以使用Beanutify。
setting 代码
{
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"beautify.config": "",
"beautify.language": {
"js": {
"type": [
"javascript",
"json",
"jsonc"
],
"filename": [
".jshintrc",
".jsbeautifyrc"
]
},
"css": [
"css",
"less",
"scss"
],
"html": [
"htm",
"html",
"vue"
]
},
"editor.fontSize": 18,
"[javascript]": {
"editor.defaultFormatter": "HookyQR.beautify"
},
"[html]": {
"editor.defaultFormatter": "HookyQR.beautify"
},
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"emmet.excludeLanguages": [
"markdown"
],
"security.workspace.trust.untrustedFiles": "open",
"explorer.confirmDelete": false,
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"emmet.preferences": {},
"editor.formatOnType": true,
"javascript.format.insertSpaceBeforeFunctionParenthesis": false,
"explorer.confirmDragAndDrop": false,
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single",
"editor.tabSize": 2,
"editor.wordWrapColumn": 100,
"editor.formatOnSave": true,
"breadcrumbs.enabled": true,
"prettier.semi": false,
"prettier.singleQuote": true,
"prettier.eslintIntegration": true,
"vetur.format.defaultFormatter.html": "prettyhtml",
"editor.renderControlCharacters": true,
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "html",
"autoFix": true
},
{
"language": "vue",
"autoFix": true
}
],
"vetur.format.defaultFormatterOptions": {
"prettier": {
"singleQuote": true,
"semi": false
}
}
}
|