views:

213

answers:

3

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

<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.

Does anyone have any ideas?

Many thanks!

+2  A: 

You were close...

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

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.

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

scoob
I thought that as a possibility too, but after trying it, I realized that option is for the HTML tag <embed></embed>. Thanks for taking a stab.
Dan
A: 

Did you ever find an answer to this? I'm curious too!

Altonymous
Unfortunately, no... if you happen to find an answer to this, do tell. There just has to be a way :)
Dan
I did find an Microsoft article about this. It's "working as intended" There is a trick though. If you always put a space after the %> it will do the line feed. This is because it's not sure if you are trying to concatenate two strings together sort of thing. So I guess it's good in it's design. :)
Altonymous
+1  A: 

Tools > Options > Text Editor > Html > Formatting

Tag wrapping section -> Tag Specific Options...

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

tman
That was the correct setting, but the value needed to be "None" in order to make it work the way I wanted it to (<h1><%# Eval("Field") %></h1>). Thanks for the lead!
Dan