Rakka Rage
Rakka Rage

Reputation: 19419

VSCode puts empty lines between styles?

I can prevent extra blank lines in the HTML part of my file with this:

"html.format.extraLiners": " "

but how can I prevent extra blank lines between styles from the style section at the top of the file?

<html>
<head>
    <style>
        #c {
            background-color: red;
        }

        #b {
            background-color: green;
        }

        #c {
            background-color: blue;
        }

    </style>
</head>
<body>
    <div id="a">A</div>
    <div id="b">B</div>
    <div id="c">C</div>
</body>
</html>

Thanks.

Upvotes: 4

Views: 970

Answers (1)

tim92109
tim92109

Reputation: 102

I've looked for what should be a simple solution to this for a long time. Didn't want to install an extension just to handle something so simple, but that's the only way I've found to fix it...

  • Install Beautify.
  • Create file .jsbeautifyrc in your directory structure above wherever you want it to work. I put it in my main projects folder so it works on everything.
  • Add the rule below to the file.

    { "newline_between_rules": false }

Upvotes: 3

Related Questions