Francesco
Francesco

Reputation: 103

VS Code: auto format html does not work

In VS Code I am having trouble in formatting HTML.

For example, I write a list of tags inline and I press Shift+Alt+F and nothing happens.

I noticed this:

If I write:

<div><span><p></p></span></div> 

nothing happens when I do the auto format.

If I write:

<div><div><div></div></div></div>

then it becomes:

<div>
    <div>
        <div></div>
    </div>
</div>

hope this will help you to help me...

Upvotes: 2

Views: 6729

Answers (3)

Gabriel Gomes
Gabriel Gomes

Reputation: 1

This is a VS code bug. I installed the 1.17 and it worked very well https://code.visualstudio.com/updates/v1_17

Upvotes: 0

Maxxx
Maxxx

Reputation: 3595

There are a certain list of tags that are ignored when auto formatting - these are defined in the setings.json file under

html.format.unformatted":

So go to settings (Command-Comma on a mac) and search for that setting and remove the tags you do want formatting.

The bad news is that it still doesn't format how I think it should - i.e. the isn't indented inside the but it at least puts it on a new line for you!

Upvotes: 2

Tom Droste
Tom Droste

Reputation: 1324

We had the same problem in my dev team. Please check or try the following things:

  • Are the keyboard bindings correct?
  • Is selected code language HTML?
  • Have you restarted VS code?
  • Begin a small piece of the formatting and then try again (for some reason it thinks its already correct.

Upvotes: 2

Related Questions