Vetur: Prettier html formatting forces attributes to wrap, need better html formatting option

Created on 26 Nov 2018  路  8Comments  路  Source: vuejs/vetur

Problem

I read the news about prettier supporting vue files. After the update came i saw how it formats. This is not usable or configurable. Tried prettyhtml but can't configure it too. First screenshot demonstrate how ugly and unreadable prettier formats html.

screen shot 2018-11-26 at 19 07 46

screen shot 2018-11-26 at 19 08 07

question

Most helpful comment

For anyone interested

"vetur.format.defaultFormatter.html": "js-beautify-html",
  "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes": "aligned-multiple"
    }
  },

More info:
https://github.com/beautify-web/js-beautify
https://vuejs.github.io/vetur/formatting.html#settings

All 8 comments

There is no prettier support yet. See #950.

It is configurable, read docs please https://vuejs.github.io/vetur/formatting.html.

@octref But it seems it works. prettyhtml use it internally.

@octref I tried all html formatting options on the docs. I guess there are 3 of them.
How can we disable wrapping attributes?

Use the js-beautify-html one.

For anyone interested

"vetur.format.defaultFormatter.html": "js-beautify-html",
  "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes": "aligned-multiple"
    }
  },

More info:
https://github.com/beautify-web/js-beautify
https://vuejs.github.io/vetur/formatting.html#settings

"vetur.format.defaultFormatterOptions": {
        "js-beautify-html": {
            "wrap_attributes": "aligned-multiple"
        },
        "prettyhtml": {
            "printWidth": 400,
            "wrapAttributes": false
        }
    },

For anyone interested

"vetur.format.defaultFormatter.html": "js-beautify-html",
  "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes": "aligned-multiple"
    }
  },

More info:
https://github.com/beautify-web/js-beautify
https://vuejs.github.io/vetur/formatting.html#settings

Cheers! This fixed it! :)

Prettier now supports better formatting.

Was this page helpful?
0 / 5 - 0 ratings