VSCode 中的自动缩进 <head> 和 <body>

zab*_*rob 7 html autoformatting visual-studio-code

VSCode 的格式化程序默认不缩进<head><body>标记。在默认设置中,存在以下几行:

// Indent <head> and <body> sections.
"html.format.indentInnerHtml": false,
Run Code Online (Sandbox Code Playgroud)

我尝试html.format.indentInnerHtml在用户设置中设置为,true但它没有改变任何东西。

这就是我得到的:

<html>

<head></head>

<body></body>

</html>
Run Code Online (Sandbox Code Playgroud)

这就是我要的:

<html>

    <head></head>

    <body></body>

</html>
Run Code Online (Sandbox Code Playgroud)

小智 5

文件/首选项/设置

或捷径

Ctrl+逗号

并将html.format.indentInnerHtml更改为true.

{
  "html.format.indentInnerHtml": true
}
Run Code Online (Sandbox Code Playgroud)

本网站上更多有用的设置

https://code.visualstudio.com/docs/languages/html#_formatting


zab*_*rob 0

我安装了“JS-CSS-HTML Formatter”扩展,这是导致问题的原因。卸载后,一切都按预期工作。