Condividi tramite


The Best of Visual Studio 2010: Using Hide Selection

Keyboard:  CTRL + M, CTRL + H (hide selection); CTRL + M, CTRL + U (stop hiding current)
Menu:  Edit –> Outlining –> Hide Selection; Edit –> Outlining –> Stop Hiding Current 
Command:  Edit.HideSelection; Edit.StopHidingCurrent 
Versions:  2010
Published:  3/22/2010
Code:  vstipEdit0036

 

This is a new feature in VS2010 that absolutely rocks!  Let’s say you have a chunk of code like this:

clip_image002

 

Notice that Outlining only allows you to collapse the entire member by default (minus sign in the upper left-hand corner).  What if you want to, say, collapse the “if” statements at the top?  In prior versions you were out of luck but NOW you can do it.  First, select the chunk of code you want to hide:

clip_image004

 

Now either press CTRL + M, CTRL + H or go to Edit –> Outlining –> Hide Selection on your Menu Bar to get this:

clip_image006

 

Congratulations!  You have successfully collapsed a custom region of code!  Now you can expand and collapse the custom area as long as you like.  Also, if you ever want to get rid of the custom region, just press CTRL + M, CTRL + U or go to Edit –> Outlining –> Stop Hiding Current to remove the custom region.