vs code vue 格式化 標簽屬性不換行


1.

 

 差不多以上這些插件,框出來的是直接相關的。

2.打開settings文件

 

 3.

{
// vscode默認啟用了根據文件類型自動設置tabsize的選項
"editor.detectIndentation": false,
// 重新設定tabsize
"editor.tabSize": 4,
// #每次保存的時候自動格式化
"editor.formatOnSave": true,
// #每次保存的時候將代碼按eslint格式進行修復
// "eslint.autoFixOnSave": true,
// #去掉代碼結尾的分號
"prettier.semi": false,
// #使用帶引號替代雙引號
"prettier.singleQuote": true,
// #讓函數(名)和后面的括號之間加個空格
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
// #讓vue中的js按編輯器自帶的ts格式進行格式化
"vetur.format.defaultFormatter.js": "vscode-typescript",
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_line_length": 220,
"wrap_attributes": "false",
"end_with_newline": false
// #vue組件中html代碼格式化樣式
},
"prettier": {
"semi": false, //不使用分號結尾
"singleQuote": true, //使用單引號
"eslintIntegration": false //開啟 eslint 支持
}
},
// 格式化stylus, 需安裝Manta's Stylus Supremacy插件
"stylusSupremacy.insertColons": false, // 是否插入冒號
"stylusSupremacy.insertSemicolons": false, // 是否插入分號
"stylusSupremacy.insertBraces": false, // 是否插入大括號
"stylusSupremacy.insertNewLineAroundImports": false, // import之后是否換行
"stylusSupremacy.insertNewLineAroundBlocks": false,
"explorer.confirmDelete": false, // 兩個選擇器中是否換行
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.stylelint": true
},
"workbench.iconTheme": "vscode-icons",
"files.autoSave": "off",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"diffEditor.ignoreTrimWhitespace": false,
"window.zoomLevel": 0,
"atomKeymap.promptV3Features": true,
"editor.multiCursorModifier": "ctrlCmd",
"editor.formatOnPaste": true,
"guides.enabled": false,
"eslint.format.enable": true,
//autoFix默認開啟,只需輸入字符串數組即可
"eslint.validate": [
"javascript",
"vue",
"html"
],
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.fontSize": 16,
"vetur.validation.template": false,
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
// 關閉eslint 語法檢測
"eslint.enable": false,
"vetur.format.defaultFormatter.html": "js-beautify-html",
"diffEditor.wordWrap": "off"
}
 
4.這步最重要,不然一切都扯淡,我看了網上好多博客,都不寫以下這步。
在你的項目根目錄下創建文件.prettierrc
注意,文件名前面的小點是要的,就是說文件名是包含那個小點的,文件內容如下:
{
"tabWidth": 2,
"useTabs": false,
"printWidth": 3000,
"semi": false,
"singleQuote": true,
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "auto",
"eslintIntegration": false,
"htmlWhitespaceSensitivity": "ignore",
"ignorePath": ".gnore",
"trailingComma": "none"
}
5.為了方便格式化,一般建議打開保存時自動格式化等功能

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM