是否可以使用Visual Studio HTML格式来格式化嵌入的代码块?

时间:2022-08-08 20:28:36

I love Visual Studio's ability to auto format (CTRL + K,D). However, in HTML if you have something like:

我喜欢Visual Studio的自动格式化功能(CTRL + K,D)。但是,在HTML中,如果你有类似的东西:

<h1><%# Eval("SomeField") %></h1>  

It gets formatted this way:

它以这种方式格式化:

<h1>
    <%# Eval("SomeField") %></h1>

I'm fairly certain that the line break after the <h1> tag is caused by Visual Studio's formatting rules for embedded code blocks. However I don't know where to edit those settings. All of the other rules are under Tools > Options > Text Editor.

我非常确定

标记之后的换行符是由Visual Studio的嵌入式代码块格式规则引起的。但是我不知道在哪里编辑这些设置。所有其他规则都在工具>选项>文本编辑器下。

Does anyone have any ideas?

有没有人有任何想法?

Many thanks!

3 个解决方案

#1


Tools > Options > Text Editor > Html > Formatting

工具>选项>文本编辑器> Html>格式

Tag wrapping section -> Tag Specific Options...

标签包装部分 - >标签特定选项...

Default Settings (there are 4) - Change all the "Line breaks:" to "Before and after"

默认设置(有4个) - 将所有“换行符:”更改为“之前和之后”

#2


You were close...

你很亲密......

Go to Tools > Options > Text Editor > Html > Format

转到工具>选项>文本编辑器> Html>格式

In the tag wrapping section, click on "Tag Specific Options"

在标记包装部分中,单击“标记特定选项”

In the tree, under the "Client HTML Tags" node you'll see the embed element.

在树中,在“客户端HTML标记”节点下,您将看到embed元素。

Set its line breaks to "Before Opening,within, and after closing."

将其换行符设置为“在打开之前,之内和之后”。

#3


Tag Specific Options->Default Settings->Client tag does not support content.

标签特定选项 - >默认设置 - >客户端标签不支持内容。

Set the Line Breaks to after tag.

将换行符设置为标记后。

#1


Tools > Options > Text Editor > Html > Formatting

工具>选项>文本编辑器> Html>格式

Tag wrapping section -> Tag Specific Options...

标签包装部分 - >标签特定选项...

Default Settings (there are 4) - Change all the "Line breaks:" to "Before and after"

默认设置(有4个) - 将所有“换行符:”更改为“之前和之后”

#2


You were close...

你很亲密......

Go to Tools > Options > Text Editor > Html > Format

转到工具>选项>文本编辑器> Html>格式

In the tag wrapping section, click on "Tag Specific Options"

在标记包装部分中,单击“标记特定选项”

In the tree, under the "Client HTML Tags" node you'll see the embed element.

在树中,在“客户端HTML标记”节点下,您将看到embed元素。

Set its line breaks to "Before Opening,within, and after closing."

将其换行符设置为“在打开之前,之内和之后”。

#3


Tag Specific Options->Default Settings->Client tag does not support content.

标签特定选项 - >默认设置 - >客户端标签不支持内容。

Set the Line Breaks to after tag.

将换行符设置为标记后。