How to collapse all classes outlining in Visual Studio

Visual Studio-2010Keyboard Shortcuts

Visual Studio-2010 Problem Overview


Ctrl+M+O works really great to collapse all methods in a class however I have a hard time finding a way to collapse all classes outlining in the whole file.

One may ask - why do you have many classes in one file ? It's because I'm using MSpec and classes are my tests so I have files with tens of classes. In order to wrap my head around what is going on I often have to collapse classes one by one but that is not really efficient.

Visual Studio-2010 Solutions


Solution 1 - Visual Studio-2010

Ha -- well, apparently I just needed to offer a bounty before I would discover an answer minutes later.

CtrlM, CtrlL will toggle all outlining. If anything in the file is collapsed, the first time you invoke this will expand everything and then invoking it again will collapse everything. This also collapses the namespace, which is a small inconvenience, but I'll call it progress.

Solution 2 - Visual Studio-2010

The accepted answer is the roundabout way of doing it.

You're looking for Ctrl + M, A, which collapses all.

As Jay mentioned, Ctrl + M, L expands all, but collapses all if already expanded.

Solution 3 - Visual Studio-2010

Actually, I found it more convenient to use CtrlM, CtrlM and specify the range:

  • To collapse everything in a file I press: CtrlA and CtrlM,CtrlM.
  • To collapse only a few sections I press: shiftPgUp/PgDn or shiftMouseClick then CtrlM,CtrlM.

This will toggle just like CtrlM,CtrlL but you decide the range!

It comes in handy to collapse multiple object initializers within a single method / everything before and after the working area. Also to expand a few relevant full-property / region / function / foreach.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDawid KowalskiView Question on Stackoverflow
Solution 1 - Visual Studio-2010JayView Answer on Stackoverflow
Solution 2 - Visual Studio-2010DanielView Answer on Stackoverflow
Solution 3 - Visual Studio-2010AlbView Answer on Stackoverflow