I uninstalled all the extensions and reinstalled vetur several times, vue code formatter still doesn't work.

{
"window.openFilesInNewWindow": "off",
"explorer.confirmDelete": false,
"[vue]": {
"editor.formatOnSave": true,
},
"files.associations": {
"*.vue": "vue"
}
}
I found that formatting will happen when I save file, but only formats JS and CSS, html is not formatted.

But still ctrl+k, ctrl+f(command for code formatting) doesn't work.
https://github.com/vuejs/vetur/blob/master/docs/formatting.md. Where is this setting?
"vetur.format.defaultFormatter": {
"html": "none",
"css": "prettier",
"postcss": "prettier",
"scss": "prettier",
"less": "prettier",
"js": "prettier",
"ts": "prettier",
"stylus": "stylus-supremacy"
}
I added the following setting to .vscode/settings.json.
{
"vetur.format.defaultFormatter.html": "js-beautify-html"
}
The formattingOnSave for HTML does work.
--
update: How to edit .vscode/settings.json?
ctrl + shift + p > Configure Language Specific Settings > Vue > Edit the file.
My current settings:
{
"window.openFilesInNewWindow": "off",
"explorer.confirmDelete": false,
"[vue]": {
"editor.formatOnSave": true,
},
"files.associations": {
"*.vue": "vue"
},
"vetur.format.defaultFormatter.html": "js-beautify-html"
}
I think this has some more info about why it is disabled: https://github.com/vuejs/vetur/issues/484
me too,Ctrl+K,Ctrl+F doesnot work, it has been resolved??
As @cmnzs has said, html formatting is disabled by default because our formatter doesn't work well enough.
@lzl124631x
I'm curious about why you are getting "No formatter installed" error.
If you remove this:
"files.associations": {
"*.vue": "vue"
}
Do you still get that error?
@percy507 That is WRONG advice. You should not associate Vue with html.
I solved this by removing all parameters in template tag (e.g. src, lang)
Mine is fixed.
Try go to vetur configuration, and change => "vetur.format.defaultFormatter.html": "js-beautify-html"
me too,Ctrl+K,Ctrl+F doesnot work, it has been resolved??
this problem has been resolved?
I added the following setting to .vscode/settings.json.
{ "vetur.format.defaultFormatter.html": "js-beautify-html" }The
formattingOnSavefor HTML does work.
- Why is the default html formatter disabled?
- Can you add "where to add those json config"? You only listed those json but didn't say where to put it.
--
update: How to edit .vscode/settings.json?
ctrl + shift + p> Configure Language Specific Settings > Vue > Edit the file.My current settings:
{ "window.openFilesInNewWindow": "off", "explorer.confirmDelete": false, "[vue]": { "editor.formatOnSave": true, }, "files.associations": { "*.vue": "vue" }, "vetur.format.defaultFormatter.html": "js-beautify-html" }
its work, thank you...
Most helpful comment
I added the following setting to .vscode/settings.json.
The
formattingOnSavefor HTML does work.--
update: How to edit .vscode/settings.json?
ctrl + shift + p> Configure Language Specific Settings > Vue > Edit the file.My current settings: