The solution to VSCode formatting and saving HTML tag names (head, body, /html) automatically blanking a line

When writing code, after formatting and saving, it is found that there will be an extra blank line in front of the label name such as head, body, div, etc., as shown below:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

</body>

</html>

But the code I want is like this:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

</body>
</html>

For comparison, the second code is more attractive and does not take up extra lines. Otherwise, the more code is written, the more blank lines will be.

I am editing in setting.json in HTML>Format: Extra Liners in the settings:

Typed an empty string in " " of html.format.extraLiners, then save and exit.

 Now when you write code, format and save, there will be no more blank lines:

In addition, if you want the css code in the style tag not to wrap, you can add the following code to setting.json:

Guess you like

Origin blog.csdn.net/weixin_44566194/article/details/125909220