ASP.NET Tip 3. Why Bother using the Mouse for markup selection?
For more tips like this, LIVE and IN PERSON, come see us at the MSDN Roadshow !
For those of you who try to avoid using the mouse at all costs, good news. We now have structured selection.
What does that mean? Do you have moments where you are using your mouse to carefully highlight a chunk of code to move it or delete it? And then you hit F5 and find out that you inadvertently missed a tiny little microscopic angle bracket or several >>>>>>>>>>? Sometimes you won’t realize it until you are far with gone improperly nesting elements and royally jumbling your code.
Visual Studio 2010 introduces the concept of structured selection, where you can select an element from a tab and have the code editor automatically highlight the corresponding chunk of code, making it easy to avoid missing a closing tag. You’ll see all the different objects of your markup below the Code Editor. Try selecting different ones. Notice that for elements that have children, you can pull down a small drop down to either select the tag holistically, or only the contents inside the tag.
WPF and Expression users have enjoyed element mapping from day 1 in Blend. Hopefully, as user interfaces get more and more complex we’ll see more synchronized selection between visual & code representations of a single element.
There is a similar, albeit slower feature in Visual Studio 2008 – the Document Outline. This load the entire DOM into memory; however once loaded provides the same functionality where you can click on an item in the Document Outline, and have it select the relevant element in the code window. By default, the Document Outline is not shown. Select View, Other Windows, Document Outline (or for non-mouse lovers: CTRL+ALT+T) to show the Document Outline viewer.