Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do not add extra newline before <head> and <body> tags with VSCode's autoformatter

VSCode's formatter automatically inserts a newline before <head> and <body> tags and also before the closing </html> tag by default. In the default settings the following lines exists:

// List of tags, comma separated, that should have an extra newline before them. 'null' defaults to "head, body, /html".
"html.format.extraLiners": null,

I tried setting html.format.extraLiners in the user settings to "" and also to "none" 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 226
zabbarob Avatar asked May 10 '16 15:05

zabbarob


People also ask

How can you prevent VS Code from breaking up long HTML lines into multiple lines?

How can you prevent VS Code from breaking up long HTML lines into multiple lines? My solution: Select the SVG you want to convert to single line. Then press F1 and type Join Lines and hit enter.

How do I get the HTML structure in VS Code shortcut?

To do this you need to navigate to Code > Preferences > User Snippets and search for 'html. json'. Then you add your custom snippets into this file.


1 Answers

I had the "JS-CSS-HTML Formatter" extension installed, which was causing the problems. After uninstalling it, everything now works as expected.

like image 142
zabbarob Avatar answered Sep 17 '22 17:09

zabbarob