What are shortcuts for expand / collapse all regions in Visual Studio?

Regions in code break up  a code and make it easy to look thru.

CTRL+M CTRL+M (that's two key presses!) - collapse/open the current parent region

CTRL+M CTRL+L - Collapse/Open all regions in document recursively (meaning you might get only one line in the document - one big namespace region which is collapsed or you'll see the entire page code uncollapsed

CTRL+M CTRL+O - Collapse all regions not recursively

 


Posted on Friday, June 13, 2008 by | Comments (32) | Add Comment

Comments

Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

This i use in shortcut in my software to user frendly

Posted on 7/24/2008 10:46:12 AM by mahendra #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

Thanks

Posted on 11/28/2008 9:53:33 PM by Amit Prajapati #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

thank you, very useful

Posted on 10/22/2009 6:49:52 AM by Thanker #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

Thanks. I needed that.

Posted on 11/6/2009 2:14:48 AM by Emre #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

Beautiful!

Posted on 11/24/2009 8:40:54 AM by Thankful #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

CTRL + M and CTRL + L doesn't work like that for me in vs2008. It just opens the "namespace" region, not the nested regions.

Posted on 12/4/2009 2:49:40 PM by Chris May #
Gravatar

Very strange. Just tried for myself. It works.

Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

Its gonna help all, very nice. post new ideas too, some about snippets and all

Posted on 2/1/2010 11:50:12 PM by Rino Reji #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

thx

Posted on 3/4/2010 9:53:08 AM by TaTT_DoGG #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

Cool. Thanks

Posted on 4/7/2010 6:52:07 AM by Oz #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

Hi All,

Just press 'CTRL' + 'm' then while holding CTRL press 'o' this will collapse all subs etc. It will not collapse the Class itself. Also Look at Using Region "???" End Region, this is great for tiding code.

Kind Regards
John Galvin
www.sassytoll.com

Posted on 4/14/2010 7:45:05 AM by John Galvin #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

Actually... i'd be far more interested in how to disable this feature all together. It causes so many problems. When you enter a file, unless you know specifically what you need to change and the change is small... It might help. But if you have to search, have any questions, or do any general editing. You have to waist your time expanding all these regions somebody thought was a good idea to put in. It's incredibly irritating.

Posted on 12/14/2010 9:39:35 AM by Ryan #
Gravatar

This is why there is a shortcut to expand them all :-).

Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

CTRL + M P will expand all and CTRL + M O will collapse all the reagions/function code blocks.

Posted on 1/7/2011 11:03:26 PM by Arjun #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

Thank you very much @Thankful

Posted on 3/3/2011 7:53:17 AM by anonymous #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

If you want to permanently disable regions. Go to the Tools->Options menu. Go to Text Editor->C#->Advanced. Uncheck "Enter outlining mode when files open".

That will disable all outlining, including regions, for all c# code files.

Posted on 5/18/2011 12:25:11 PM by Jonathan Winters #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

Thank youuuu !

Posted on 9/15/2011 1:42:45 AM by Mike #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

As I hate comments/regions, I've disabled regions as was advices above and used CodeRush to paint xml comments and regions text using white color, therefore they became invisible on screen :) Thank you for advice of disabling regions!

Posted on 9/30/2011 12:16:05 AM by Kirill Medvedev #
Gravatar

Re:What are shortcuts for expand / collapse all regions in Visual Studio?

Thank you for posting these shortcuts

Posted on 11/22/2011 6:42:48 AM by thank you #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

thanks alot

Posted on 1/18/2012 1:22:30 AM by zulfiqar langah #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

ctrl+M+P will open all the regions in the code of visual studio

Posted on 2/20/2012 8:10:33 PM by rajesh #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

So useful. Thanks a lot.

Anybody knows how to expand regions of all documents in a project, not just a document?

Posted on 2/28/2012 11:31:06 AM by Sangkun Park #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

Thank you .... :D

Posted on 3/15/2012 4:50:41 AM by Moumit Mondal #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

thank you nice post

Posted on 4/2/2012 1:35:48 AM by sandeep #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

WOW, many thanks for that shortcut! One of the most anoying things is that VS.NET is configured to open all files by default with all segments expanded - so if oyu are working with large projects this may be a PITA...
Thanks!
Lelala
http://www.lelala.ch

Posted on 7/20/2012 12:28:19 PM by Lelala #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

Thanks for the helpful info

Posted on 8/18/2012 12:34:04 AM by Lakshman C B #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

CTRL+M CTRL+O - Collapse all regions not recursively
Thank You for that !!!

Posted on 10/5/2012 8:00:03 PM by westseyi #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

Correction: CTRL + M, CTRL + L does not work anymore.
You can use CTRL + M, CTRL + P instead to expand all regions.

Posted on 1/23/2013 6:16:22 AM by Karanvir #
Gravatar

CTRL+M, CTRL+L still works for me in VS2010 + Resharper 7

Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

thanks a lot

Posted on 2/14/2013 12:54:33 AM by mahdi #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

Thank you very much.

Posted on 3/18/2013 1:02:48 PM by tj #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

Thanks !!!!!!!

Posted on 5/6/2013 11:31:36 PM by Gunjan Arora #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

thanks a lot

Posted on 1/27/2014 12:53:16 AM by qq #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

excellent!

Posted on 3/18/2014 1:22:11 PM by J #
Gravatar

Re: What are shortcuts for expand / collapse all regions in Visual Studio?

When I write a code inside the region and collapse it..after to it If would be searching the some text which is inside the region its showing zero (0) results,it seems visual studio doesn't search text inside collapsed region ..is there any trick to enable that search

Posted on 4/29/2014 3:17:49 AM by Mohd Ilyas #
Gravatar

I just tried, Visual Studio 2012 searches text in collapsed region. I guess a trick is to upgrade to VS2012 or VS2013 :-).

New Comment

Your Name:
Email (for internal use only):
Comment:
 
Code above:

Categories

Valid HTML5