37

How can I collapse / expand all projects in Solution Explore using keyboard?

Vadim
  • 21,044
  • 18
  • 65
  • 101

5 Answers5

89

In Visual Studio 2013 it is finally just part of solution explorer... with a "Collapse All" icon. enter image description here

The right click option available with earlier versions of power tools in is not there but clicking the icon is easier anyway.

Chad Dienhart
  • 5,024
  • 3
  • 23
  • 30
  • 1
    +1 because I've been looking for the 2013 equivalent of Power Commands and this was truly the only reason why. – Matt Jul 08 '15 at 14:45
  • Any idea what the keyboard binding is for that? (not the keys, but what this is called in the Options | Keyboard dialog? – Peter McEvoy Jun 02 '16 at 12:35
  • @PeterMcEvoy SolutionExplorer.CollapseAll (And Shift-Ctrl-Alt-L works well as the keyboard binding [to go with Ctrl-Alt-L to activate solution explorer]) – Ruben Bartelink Jun 02 '16 at 20:23
  • Hmm - I can't see that command. Closest is a R# one (but I know you're a coderush guy) or a powercommands one - but that doesn't close sln folders. The search continues.... – Peter McEvoy Jun 07 '16 at 08:55
  • @PeterMcEvoy Hmm, That's on 2015 community (I happen to have CR for Roslyn installed but that's a lot less invasive than CR was - and CR does not emit inject commands into that set - I guess it may be down to it not being exposed in the VS you have - maybe is in Update 2 [which I have on this box] ?). See [this other answer](https://stackoverflow.com/a/35093599/11635) for confirmation of its existence (I never actually spotted the weakness cited in that post as I only ever look for it after I switch to it) :) – Ruben Bartelink Jun 07 '16 at 21:31
  • Hilarious -- thinking there HAD to be a difficult answer to this, I read Null's note above. Said to myself 'oh really ...' right away skeptical that this icon would now be removed in 2019. :) Nope, works great. – user1585204 Dec 02 '20 at 11:54
23

The *, + and - on the numeric pad controls do this:

  • Open the solution explorer, select the folder to expand and press *.

  • To collapse, press -.

  • Then if you have collapsed some sub-folders, press + to return to your partially collapsed version.

Jay Sullivan
  • 17,332
  • 11
  • 62
  • 86
EddyQ
  • 231
  • 2
  • 3
  • 3
    * does a recursive expansion, +/- expand/collapse the selected folder/project. For some reason there appears to be no recursive collapse; some tools assign that function to '/' - but not VS (as far as I can tell) – redcalx Jan 30 '12 at 10:30
11

Power Commands for VS2008 has a command to do this, plus lots of other neat tools

http://code.msdn.microsoft.com/PowerCommands

You could also write a macro to do it, and assign it to a key combination

http://weblogs.asp.net/israelio/archive/2007/09/06/visual-studio-collapse-selected-node.aspx

Jason
  • 86,222
  • 15
  • 131
  • 146
6

Press CTRL+ALT+L to focus on Solution Explorer. If it's not on the screen, or it's collapsed, this will focus on it.

Then press your left arrow key as many times as it takes to get to the solution, and with another left, it'll collapse the whole tree.

I jsut tested VS2008, and you can also press HOME, to get to the top of the tree.

If what you want, is the solution open, and all the project files closed, then ....

once you're home in the tree view, press down,left for each open project and|or open solution folder (if you have those).

The power tools that @Jason mentioned, might have a different solution, but this is how you can navigate the Solution Tree without any add-ins.

ScottCate
  • 2,365
  • 7
  • 21
  • 35