I had this problem: How to preserve empty lines when formatting .vue files in VScode?
I solved it by telling VScode (bottom right corner) that a .vue file should be formatted as a .html file.
That fixed the formatting issue, but I lost syntax highlighting for vue attributes in the html tags.
I need to get VScode to format file-type .vue as .html, while preserving syntax highlighting.
How can that be done?
Syntax highlighting for .vue comes from extensions.
I tried Vetur extension and vue-beautify extension. They highlighted the syntax but didn't format the .vue file correctly (for me at least)
In tried to add the following line in the VScode's global settings.json
{
"[vue]": {
"editor.defaultFormatter": "vscode.html-language-features"
}
}
But it didn't work for both of them.
Vetur just ignored the setting and formatted the .vue file following Prettier rules. (which you can't change in Vetur settings)
While with vue-beautify threw that there's no formatter installed for .vue files. Although I explicitly specified that I want to use the build in HTML formatter.
How can I force VScode to use the built in HTML formatter for .vue files, while still using all the rest of the features that "Vetur" or "vue-beautify" provide?
OR
How can I tell "Vetur" or "vue-beautify" extensions' "Prettier-html" module to preserve empty newlines?
UPDATE: - tried "unibeautify".. but no support for "preserve-max-newlines" feature for vue - and "beautify" - no support for vue at all. - and "pretier" - no support for "preserve-max-newlines" for vue
