【问题标题】:What does VS Code's setting html.format.unformatted do?VS Code 的设置 html.format.unformatted 有什么作用?
【发布时间】:2019-10-01 23:31:07
【问题描述】:

我试图弄清楚 VS Code html.format.unformatted 设置的作用,但我不知道。

我在 GitHub 中找到了 this issuethis issue,但它什么也没解释。

有人可以向我解释一下html.format.unformatted 设置的作用以及它与html.format.contentUnformatted 设置的区别吗?

【问题讨论】:

    标签: visual-studio-code vscode-settings


    【解决方案1】:

    经过反复试验,我发现了这一点:

    TLDR:

    • html.format.unformatted: 不格式化标签本身也不格式化内容
    • html.format.contentUnformatted: 将格式化标签而不是内容

    来源(不是很清楚,恕我直言):https://code.visualstudio.com/Docs/languages/html


    示例 html 代码(无效,我知道,但在这里无关):

    <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>
    

    有了这个配置:

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

    当我们在上面的示例 html 上触发自动格式化时,STYLE TAG 没有被格式化并且 style 标记的内容没有改变。

    有了这个配置:

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

    当我们在上面的示例 html 上触发自动格式化时,样式标签被格式化(空格、标识等),样式标签内容没有改变。

    【讨论】:

    • 哇,谢谢!我花了很多时间试图弄清楚这一点,但我使用的是 "html.format.wrapAttributes": "auto" 所以标签本身并没有改变。
    猜你喜欢
    • 2020-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-18
    • 2020-11-05
    • 1970-01-01
    • 2021-08-17
    • 2017-07-26
    相关资源
    最近更新 更多