VSCode's formatter doesn't indent <head>
and <body>
tags by default. In the default settings the following lines exists:
// Indent <head> and <body> sections.
"html.format.indentInnerHtml": false,
I tried setting html.format.indentInnerHtml
in the user settings to true
but it didn't change anything.
This is what I get:
<html>
<head></head>
<body></body>
</html>
This is what I want:
<html>
<head></head>
<body></body>
</html>
Command Palette VS Code is equally accessible from the keyboard. The most important key combination to know is Ctrl+Shift+P, which brings up the Command Palette. From here, you have access to all of the functionality of VS Code, including keyboard shortcuts for the most common operations.
If you prefer using [spacebar] to indent your code rather than using [tab], you can select multiple lines by holding the [alt] key and clicking on the beginning of each line you want to indent. Then, you can press [spacebar] and all the selected lines will be affected.
Just right-click on the text and select "Format code". Visual Studio Code uses js-beautify internally, but it lacks the ability to modify the style you wish to use. The extension "beautify" lets you add settings.
File/Preferences/Settings
or shortcut
Ctrl+Comma
and change html.format.indentInnerHtml to true
.
{
"html.format.indentInnerHtml": true
}
more helpful settings on this website
https://code.visualstudio.com/docs/languages/html#_formatting
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With