vscode使用Eslint + prettier + beautify 格式化vue 代码不换行

设置--首选项-vetur--settings.json

 

{

  // 是否允许自定义的snippet片段提示

  "editor.snippetSuggestions": "top",

  "editor.fontSize": 22,

  "editor.fontWeight": "400",

  // 配置文件关联,以便启用对应的提示

  "files.associations": {

    "*.vue": "vue",

    "*.wxss": "css"

  },

 

  "window.zoomLevel": 0,

  "javascript.updateImportsOnFileMove.enabled": "always",

  "vetur.validation.template": false, // 使用eslint插件时需要把此项设置为false

  "vetur.validation.script": true, //检查js代码

  "vetur.validation.style": true, //能检查css的属性是否存在,分隔符是否正确,

  "vetur.format.defaultFormatter.html": "js-beautify-html", //默认采用js-beautify-html格式化

  "editor.tabSize": 2,

  "editor.formatOnSave": true, // 每次保存自动补全校验

  "vetur.format.defaultFormatterOptions": {

    //对vue文件html的格式化,对js的格式化在全局的prettierrc.json文件控制

    "js-beautify-html": {

      "wrap_attributes": "aligned-multiple",

      "indent_size": 2, //缩进大小

      "indent_char": " ", //缩进字符

      "indent_with_tabs": false,

      "eol": "\n", // 用作行终止的字符,默认为\n

      "end_with_newline": true, //是否用换行符结束

      "preserve_newlines": true, // 是否保留现有的换行符

      "max-preserve-newlines": 1200, // 一次可保留的最大换行数

      "indent-inner-html": true, //缩进 head body代码片段

      "wrap_line_length": 1200, //超过多少字符换行

      "editorconfig": false //使用editorconfig设置选项

    },

    "prettyhtml": {

      "printWidth": 1000,

      "singleQuote": false,

      "wrapAttributes": false,

      "sortAttributes": false

    }

  },

  "vetur.format.defaultFormatter.js": "vscode-typescript",

  "[jsonc]": {

    "editor.defaultFormatter": "esbenp.prettier-vscode"

  },

  "[javascript]": {

    "editor.defaultFormatter": "esbenp.prettier-vscode"

  },

  "prettier": {

    "eslintIntegration": true

  },

  "[json]": {

    "editor.defaultFormatter": "esbenp.prettier-vscode"

  },

  "[less]": {

    "editor.defaultFormatter": "esbenp.prettier-vscode"

  },

  "[html]": {

    "editor.defaultFormatter": "esbenp.prettier-vscode"

  },

  "[vue]": {

    "editor.defaultFormatter": "octref.vetur"

  },

  "prettier.semi": true,

  "prettier.singleQuote": true,

  "html.format.maxPreserveNewLines": 1200,

  "html.format.enable": false

}

 

参考链接 https://www.cnblogs.com/felicitytanyin/p/14241526.html

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值