Right-click in your text editing area and choose Format Document With.... A popup will appear on top then choose Choose default formatter and then choose Prettier
Right-click in your text editing area and choose Format Document With.... A popup will appear on top then choose Choose default formatter and then choose Prettier
You can trigger suggestions at any time by pressing
Ctrl+Space.To improve the formatting of your HTML source code, you can use the
Format Document commandCtrl+Shift+Ito format the entire file or
Format SelectionCtrl+KCtrl+Fto just format the selected text.
Read this: https://code.visualstudio.com/docs/languages/html
Help with formatting of my HTML files in VS Code
formatting - How to format HTML code in VScode ? - Stack Overflow
Format on save messes up original HTML file format
HTML Formatter for Visual Studio?
Videos
Hey guys, do you know any good extensions for auto-formatting html? I am getting kinda tired of doing it manually...
You can also use it with combination of html.format.wrapLineLength.
"html.format.wrapLineLength": 80,
"html.format.wrapAttributes": "auto",
In this case, attributes starts wrapping when line length exceeds 80. It's useful when you have many attributes and it will fill the empty spaces on the right.
Setting the VSCode preference html.format.wrapAttributes to force will accomplish the formatting from your example.