Vscode格式化的樣式設置


 一、文件

Settings.json

 

二、路徑

  設置--->用戶(常用設置)【文本編輯器】上面--->在setting.json中編輯

 

 
三、代碼
規則1:
 1 {
 2   "files.eol": "\n",
 3   "typescript.preferences.quoteStyle": "single",
 4   "javascript.preferences.quoteStyle": "single"
 5   // tab 大小為2個空格
 6   "editor.tabSize": 2,
 7   // 編輯器換行
 8   "editor.wordWrap": "off",
 9   // 保存時格式化
10   "editor.formatOnSave": false,
11   // 開啟 vscode 文件路徑導航
12   "breadcrumbs.enabled": true,
13   // prettier 設置語句末尾不加分號
14   "prettier.semi": false,
15   // prettier 設置強制單引號
16   "prettier.singleQuote": true,
17   // 選擇 vue 文件中 template 的格式化工具
18   "vetur.format.defaultFormatter.html": "js-beautify-html",
19   // vetur 的自定義設置
20   "vetur.format.defaultFormatterOptions": {
21     "js-beautify-html": {
22       "wrap_attributes": "aligned-multiple"
23     },
24     "prettier": {
25       "singleQuote": true,
26       "semi": false,
27       "printWidth": 100,
28       "wrapAttributes": false,
29       "sortAttributes": false
30     }
31   }
32 }

 

規則2:

{
  "[html]": {
    "editor.defaultFormatter": "HookyQR.beautify"
  },
  "[javascript]": {
    "editor.defaultFormatter": "HookyQR.beautify"
  },
  "editor.tabSize": 2,
  "eslint.autoFixOnSave": true, // 每次保存的時候將代碼按eslint格式進行修復
  "prettier.eslintIntegration": true, //讓prettier使用eslint的代碼格式進行校驗
  "prettier.semi": false, //去掉代碼結尾的分號
  "prettier.singleQuote": true, //使用帶引號替代雙引號
  "javascript.format.insertSpaceBeforeFunctionParenthesis": true, //讓函數(名)和后面的括號之間加個空格
  "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": "auto" //"force-aligned" //屬性強制折行對齊
    }
  },
  "[jsonc]": {
    "editor.defaultFormatter": "HookyQR.beautify"
  },
  "javascript.format.insertSpaceBeforeFunctionParenthesis": false, //  #不讓函數(名)和后面的括號之間加個空格
  "vetur.validation.template": false,
  "[json]": {
    "editor.defaultFormatter": "HookyQR.beautify"
  },
  "html.format.wrapAttributes": "preserve",
  "search.followSymlinks": false // 阻止iview報錯
}

 


免責聲明!

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



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