Automating readable markup in ASP.NET, WPF, and Silverlight


[Update 06/07/2008]: New features have been added to this project. You can read about the new features here. In addition, ASP.NET inline code in attributes (such as Eval() statements) is now supported.

Downloads: Codeplex | Setup (VS2008)

A long time ago I was watching Joe Stagner’s ASP.NET AJAX videos and I saw him purposefully indenting the attributes in his ASP.NET markup so that they lined up neatly underneath each other. I really took to this concept because it’s so much easier to read a laundry list of attributes than it is to scroll across your page trying to hunt down your markup. I emailed Joe, asking him what the Visual Studio hotkey was to perform the lineup, and he replied that he did it all by hand. I’ve done the same thing since watching those videos and while it’s time consuming, I really prefer the readability.

Markup is much easier to read when it’s formatted in a straight line.

At DevTeach, Rob Burke gave an excellent talk on building line-of-business applications using WPF
and Silverlight . He is another practitioner of listed attributes, and watching him painstakingly line them up by hand during the presentation was the last straw for me; I wasn’t going to waste another keystroke on presenting these attributes how we want them!

TameMenu I built a simple Visual Studio Add-In that provides an additional Edit menu item and hotkey (Ctrl+K, Ctrl+Z) to automatically line up attributes in a selection of text, or format the entire document if no text is selected. The meat of the add-in is a handful of regular expressions that parse tags (XAML, HTML, and ASP.NET directives) and a few IDE tools to line them up according to their indent level. The Visual Studio Add-In environment provides a lot of flexibility in the active document to do this, if you can find the commands.

If you’re interested in the code as an example for building your own Add-Ins, it’s available below, along with the installers for Visual Studio 2008. Enjoy!

Downloads: Codeplex | Setup (VS2008)

kick it on DotNetKicks.com

Trackbacks/Pingbacks

  1. [...] I released this tool after a weekend’s work, I didn’t anticipate that it would reach well over two thousand [...]