Break line on each tag attribute and keep them aligned in Visual Studio HTML code editor

Well, I found a trick at the ASP.NET Forums:

Positioning each attribute on a separate line

It's not like the XAML feature described in my question but it works.

In Options/Text Editor/HTML/Format you can check "Wrap tags when exceeding specific length" and set the length to 1. That will cause the formatter to wrap like crazy.


Another option is:

  1. Go to TOOLS => Options... => Text Editor => XML => Formatting => Align attributes each on a separate line.

  2. Close the .cshtml file. Right click it in Solution Explorer and select Open With... then select XML (text) Editor. Select all content and do Ctrl + K then Ctrl + F.

    * This second option is tedious! :(


If you feel brave, you can write an editor extension that does this for you. Take a look at the align extension that Noah wrote a while ago for ideas: https://github.com/NoahRic/AlignAssignments