在Visual Studio Code中格式化html代码,使属性位于单独的行上? [英] Format html code in Visual Studio Code such that attributes are on separate lines?

查看:208
本文介绍了在Visual Studio Code中格式化html代码,使属性位于单独的行上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎缺少vscode的格式设置. 我希望能够设置html格式,使我的html显示为:

There seems to be a lack of formatting settings for vscode. I want to be able to format html such that my html shows up as:

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

这是我真的很想拥有的功能!

This is one functionality that I'd really love to have!

推荐答案

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

VSCode added a way to do this now. You can edit your settings.json (ctrl+shift+p) and then add the following for the desired effect:

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

-或-

"html.format.wrapAttributes": "force"

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

force-aligned will also add indents to align it with the attribute on the line where tag was opened.

访问此链接以获取更多详细信息或更新.

Visit this link for more details or updates.

这篇关于在Visual Studio Code中格式化html代码,使属性位于单独的行上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆