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 the 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 June 13, 2008 by


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

This i use in shortcut in my software to user frendly

Posted on 11/28/2008 09:53:33 PM by Amit Prajapati


Posted on 10/22/2009 06:49:52 AM by Thanker

thank you, very useful

Posted on 11/6/2009 02:14:48 AM by Emre

Thanks. I needed that.

Posted on 11/24/2009 08:40:54 AM by Thankful


Posted on 12/4/2009 02:49:40 PM by Chris May

CTRL + M and CTRL + L doesn’t work like that for me in vs2008. It just opens the “namespace” region, not the nested regions.
Very strange. Just tried for myself. It works.

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

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

Posted on 3/4/2010 09:53:08 AM by TaTT_DoGG


Posted on 4/7/2010 06:52:07 AM by Oz

Cool. Thanks

Posted on 4/14/2010 07:45:05 AM by John Galvin

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


Posted on 7/18/2010 05:27:40 PM by Keith Ray

This is a little old but

VBNET 2010

Ctrl+m + Ctrl+m collapses everything

Ctrl+m + Ctrl+o collapses everything except class

Ctrl+m + Ctrl+L opens everything

Ctrl+m + Ctrl l opens everything

Posted on 12/14/2010 09:39:35 AM by Ryan

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.
This is why there is a shortcut to expand them all :-).

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

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

Posted on 3/3/2011 07:53:17 AM by anonymous

Thank you very much @Thankful

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

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 6/28/2011 11:41:03 AM by Paul

Where do you people find this stuff, its gold! =)

Posted on 9/15/2011 01:42:45 AM by Mike

Thank youuuu !

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

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 1/18/2012 01:22:30 AM by zulfiqar langah

thanks alot

Posted on 2/20/2012 08:10:33 PM by rajesh

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

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

So useful. Thanks a lot.

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

Posted on 3/15/2012 04:50:41 AM by Moumit Mondal

Thank you …. :D

Posted on 4/2/2012 01:35:48 AM by sandeep

thank you nice post

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

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…




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

Thanks for the helpful info

Posted on 10/5/2012 08:00:03 PM by westseyi

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

Thank You for that !!!

Posted on 1/23/2013 06:16:22 AM by Karanvir

Correction: CTRL + M, CTRL + L does not work anymore.

You can use CTRL + M, CTRL + P instead to expand all regions.

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

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

thanks a lot

Posted on 3/18/2013 01:02:48 PM by tj

Thank you very much.

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

Thanks !!!!!!!

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

thanks a lot

Posted on 3/18/2014 01:22:11 PM by J


Posted on 4/29/2014 03:17:49 AM by Mohd Ilyas

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
I just tried, Visual Studio 2012 searches text in collapsed region. I guess a trick is to upgrade to VS2012 or VS2013 :-).

Posted on 10/12/2018 12:23:52 AM by www

Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Posted on 10/8/2019 05:03:14 AM by developer

Thanks a lotç