What does VS Code's setting html.format.unformatted do?

Viewed 2503

I'm trying to figure out what the VS Code html.format.unformatted setting does, but I can't.

I've found this issue and this issue in GitHub, but it explains nothing.

Can someone please explain to me what the html.format.unformatted setting does and how it differs from the html.format.contentUnformatted setting?

1 Answers

After much trial and error i found out this:

TLDR:

  • html.format.unformatted: does not format the tag itself nor the content
  • html.format.contentUnformatted: will format the tag but not the content

source (not very clear, imho): https://code.visualstudio.com/Docs/languages/html


Sample html code (not valid, i know, but irrelevant here):

<body>

    <style class="foo"        class="foo"        class="foo"    >
            .foo {
            background-image: 'bar.jpeg';
            background-size: cover;
            background-position-x: 50%;
            background-position-y: 50%;
            }
    </style>

    <div class="foo">
        <div>
            <div></div>
            whatever
            <div></div>
        </div>
    </div>
</body>

With this config:

{
    "html.format.wrapAttributes": "force-expand-multiline",
    //"html.format.contentUnformatted" : "style",
    "html.format.unformatted": "style"
}

When we trigger an auto format on the sample html above, the STYLE TAG IS NOT formatted and the style tag content IS NOT changed.

With this config:

{
    "html.format.wrapAttributes": "force-expand-multiline",
    "html.format.contentUnformatted" : "style",
    //"html.format.unformatted": "style"
}

When we trigger an auto format on the sample html above, the STYLE TAG IS formatted (spaces, ident, etc), the style tag content IS NOT changed.

Related