html - 在 Visual Studio Code 中格式化 html 代码,使属性位于不同的行上?

标签 html formatting visual-studio-code

vscode 似乎缺少格式设置。 我希望能够格式化 html,以便我的 html 显示为:

<div attrib1=value1
     attrib2=value2
     attrib3=value3>
  Content
</div>

这是我非常想拥有的一项功能!

最佳答案

VSCode 现在添加了一种方法来执行此操作。 您可以编辑您的 settings.json (ctrl+shift+p),然后添加以下内容以获得所需的效果:

"html.format.wrapAttributes": "force-aligned"

--或--

"html.format.wrapAttributes": "force"

force-aligned 还会添加缩进以使其与打开标签的行上的属性对齐。

访问 this link了解更多详情或更新。

关于html - 在 Visual Studio Code 中格式化 html 代码,使属性位于不同的行上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33560205/

相关文章:

visual-studio-code - 如何在 Visual Studio Code for Mac 中向上或向下移动一行

powershell - 如何调整 VSCode 对 PowerShell 的支持——更好地处理引号的输入

html - 如何在同一个div中将图像和文本居中

Javascript 改变输入值

html - <链接> 与 <a> : when to use one over the other?

python 2 打印带有浮点格式且没有行返回的数组

c# - VSCode 支持变量和函数语法高亮吗?

javascript - 为什么此脚本在 FF 和 IE 中有效,但在 Google Chrome 中无效?

C++ 将变量传递给 System() WINAPI(无 MFC)

java - 在 JVM 级别重新定义 Locale 的日期时间格式