Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autoindent <head> and <body> in VSCode

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>
like image 600
zabbarob Avatar asked May 10 '16 15:05

zabbarob


People also ask

Where is command palette in VS code?

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.

How do you give a tab space to multiple lines in VS code?

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.

How do I beautify VSCode?

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.


1 Answers

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

like image 52
Jaroslav Janíček Avatar answered Oct 02 '22 06:10

Jaroslav Janíček