Moby Disk Consulting
Software Development, Training & Consulting
William Garrison - mobydisk at mobydisk daht com

Make Outlining Work Better in Visual Studio

Roland Weigelt wrote a cool macro that improves the usability of outlining. It is often useful to collapse the entire file to get a quick overview, or to navigate to a particular section of code. Visual Studio lets you collapse regions, summary headers, method bodies, classes, and namespaces....

Outlining screen shot

It is very rare that I would want to collapse all of these things. Furthermore, there is not a good set of shortcuts to collapse and expand sections of code. In general, I prefer to only collapse between #region and #endregion markers. This macro gives you shortcuts to collapse all regions, uncollapse all regions, and toggle the current region.

The macros below contain Roland's original macros, updated to work on all current versions of Visual Studio. Download the appropriate macro file:
   RegionTools.vb (for Visual Studio 2003 through 2005)
   RegionTools2010.vb (for Visual Studio 2010)

To use this macro, go to Tools - Macros - Macros IDE. Then paste the contents of the file above into a new Module named RegionTools. Save it, then go into Tools - Options - Keyboard. Assign ctrl-alt-plus to RegionTools.ExpandAllRegions, ctrl-alt-minus to RegionTools.CollapseAllRegions, and ctrl-plus and/or ctrl-minus to RegionTools.ToggleParentRegion.

Visual Studio macro setup screen shot