VScode 格式化

安装Vscode插件

  • beautify
  • Vetur

设置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
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值