【问题标题】:Autoindent <head> and <body> in VSCode在 VSCode 中自动缩进 <head> 和 <body>
【发布时间】:2016-05-10 15:34:47
【问题描述】:

默认情况下,VSCode 的格式化程序不会缩进 &lt;head&gt;&lt;body&gt; 标签。在默认设置中存在以下几行:

// Indent <head> and <body> sections.
"html.format.indentInnerHtml": false,

我尝试将用户设置中的html.format.indentInnerHtml 设置为true,但没有任何改变。

这是我得到的:

<html>

<head></head>

<body></body>

</html>

这就是我想要的:

<html>

    <head></head>

    <body></body>

</html>

【问题讨论】:

  • 确保您已将更改保存到 settings.json。

标签: html visual-studio-code autoformatting


【解决方案1】:

文件/首选项/设置

或快捷方式

Ctrl+逗号

并将 html.format.indentInnerHtml 更改为 true

{
  "html.format.indentInnerHtml": true
}

本网站上更多有用的设置

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

【讨论】:

  • 这应该被标记为正确答案。至少,这对我有用。
【解决方案2】:

我安装了"JS-CSS-HTML Formatter" 扩展,这导致了问题。卸载后,现在一切正常。

【讨论】:

  • 我没有安装 lonefy.vscode-js-css-html-formatter 扩展,Visual Studio Code 仍然没有缩进 &lt;head&gt;&lt;body&gt;
猜你喜欢
  • 1970-01-01
  • 2019-12-11
  • 2017-03-22
  • 1970-01-01
  • 2013-01-27
  • 2021-03-26
  • 2020-12-03
  • 2021-08-28
  • 1970-01-01
相关资源
最近更新 更多