Dawid Kowalski
Dawid Kowalski

Reputation: 1247

How to collapse all classes outlining in Visual Studio

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.

Upvotes: 58

Views: 24750

Answers (3)

Alb
Alb

Reputation: 529

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.

Upvotes: 2

Daniel
Daniel

Reputation: 11054

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.

Upvotes: 33

Jay
Jay

Reputation: 57919

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.

Upvotes: 91

Related Questions