Hiding the regions in Visual Studio

I hate regions (my team loves them) and was surprised to find that nobody has written an extension to make them better. I finally wrote one myself called I Hate #Regions:

Make #regions suck less (for free):

http://visualstudiogallery.msdn.microsoft.com/0ca60d35-1e02-43b7-bf59-ac7deb9afbca

  • Auto Expand regions when a file is opened
  • Optionally prevent regions from being collapsed (but still be able to collapse other code)
  • Give the #region / #end region lines a smaller, lighter background so they are less noticeable (also an option)
  • Works in C# and VB

Region Tool Screenshot


There are shortcut keys to deal with them:

Ctrl+M, Ctrl+M  Collapse or expand the block you're currently in.
Ctrl+M, Ctrl+O  Collapse all blocks in the file
Ctrl+M, Ctrl+L  Expand all blocks in the file
Ctrl+M, Ctrl+P  Stop outlining mode. (Ctrl+M, Ctrl+O resumes) 

See The Problem With Code Folding


Personally, I write a VS macro (Tools > Macro) to expand all regions on file open.