views:

38

answers:

2

In Visual Studio 2008, I've used a nice feature in its XAML editor which breaks a line so that a control's attributes are automatically positioned on new lines: one attribute per line.

Is there a way to do the same for the HTML editor?

Thank you.

A: 

I am not aware of anything that does exactly that, but there is a reformat command Edit -> Advanced -> Format document(Ctrl K + Ctrl D).

You can always write a VBA macro that does that, shouldn't be too hard.

Oded
Thank you for your reply.I am looking for some kind of an "extension" to this command.I am surprised that, while XML and [XML-based] XAML can place attributes on separate lines, the [XML-like] HTML code cannot be formatted that way...
Dmitriy
@Dmitriy - Have you tried with Html or with XHtml?
Oded
I don't see XHTML...In Visual Studio 2008, Tools ==> Options... ==> Text Editor ==> HTML.Am I missing something?Thank you.
Dmitriy
In your HTML document, what DOCTYPE are you using?
Oded
A: 

Oded, thank you very much! You gave me an idea on how to apply "one attribute per line" formatting to an ASP.NET document:

  1. In Visual Studio 2008, right-click on the .aspx file in the Solution Explorer.
  2. Select "Open With..".
  3. Select "XML Editor". [Assuming that the XML Editor has been properly configured in Tools->Options prior to doing this.]
  4. Edit -> Advanced -> Format Document.

This reformats the document so that each attribute is positioned in its own line, and all of them are nicely indented.

Of course, if I later reopen the same file in Web Forms Designer and format it again, it goes back to what it looked like before. But for my purposes (easily finding the required attributes in a large file), this temporary solution is quite sufficient.

Once again, thank you very much!

Best regards,

Dmitriy

Dmitriy