views:

236

answers:

2

I have a file with a lot of this kind of thing in it:

    <asp:TableCell ID="TableCell9" runat="server">Company 
Organization:</asp:TableCell><asp:TableCell ID="TableCell10" runat="server">

How can I get the formatter to change it to shows like this:

<asp:TableCell ID="TableCell9" runat="server">Company Organization:</asp:TableCell>
<asp:TableCell ID="TableCell10" runat="server">

What I have tried:

I opened Tools->Options then browsed to Text Editor. I got a list of Languages. I selected HTML because that is the language that controls formatting for aspx files.

I changed "tag wrapping" to not have "Wrap tags when exceeding specified length" checked.

I then pressed ctrl+k, ctrl+d (Format the document). This did not fix the problem.


What I don't want to have to do:

Edit the file manually to fix all the tags.

Any ideas?

+1  A: 

The answer should be: Tools-Options->Text Editor->HTML-Format->Tag Specific Options Then in ASP.NET Controls look for your tag. If it's not there you might need to Add it (New Tag) and set the Line breaks as you want them.

However I've found that this does not always work.Visual Studio respects the per tag colorization but Line breaks are not always respected.

So if this doesn't work for you, you might need to do a Search-Replace hack (Look for and replace with a NewLine in the middle), thenk try Format document and that should work.

krolth
+1  A: 

I found a way that works.

In the list with HTML there is a File Extension Option.

I added ASPX to that list and said to edit it with an XML editor (I suppose I could have just right clicked it and opened it with the xml editor, but I did not think of that till after).

Anyway, once it is open as an XML File I formatted it (ctrl+k, ctrl+d) and it formated the way I wanted it. I then removed the extension mapping and reopend the file again.

One last formatting adjusted the tab spacing and I was perfect!


Note: When I did this the top line had this change made: from Page Language="C#" to Page="" Language="C#" I changed it back manually and all seemed to be well.


Later Note: Sadly, Visual Studio messes up the formatting every time I run the solution. Note that pressing ctrl+k, ctrl+d is fine and keeps my nice formatting, but when I run, Visual Studio collapses it down to a very unreadable format. :( Don't know how to fix it....

Vaccano