Visual Studio: Is there a way to collapse all items of Solution Explorer?

.NetVisual Studio-2008

.Net Problem Overview


I know that I can use Arrow Keys to collapse items of solution explorer one by one, but I would like to know if there is a way to collapse all items with only one operation. I want to know it because, today I have a solution with 6 projects that have at least two hundred files and if I try to collapse them one-by-one I will have a hard time.

Tree View - Solution Explorer (Visual Studio)

.Net Solutions


Solution 1 - .Net

It appears to be built in by default in Visual Studio 2013 onwards.

Solution Explorer > Collapse

Solution 2 - .Net

If you have ReSharper installed, you can right click on the solution in the solution explorer, and select "Collapse All".

Solution 3 - .Net

You can use PowerCommands for Visual Studio 2008

Right click on the project\solution on the solution explorer and choose Collapse Project:

Solution 4 - .Net

Just use the number pad's Plus + and Minus - keys at the top-level node, to expand and collapse respectively (Note: * also expands the whole list.)

For the toolbox, you need to use * and / instead for expand/collapse. Go figure.

Solution 5 - .Net

In VS 2019 just click Collapse All

enter image description here

Solution 6 - .Net

If you have Resharper installed, there is an option called Collapse All and a shortcut key next to it.

Solution Explorer > Resharper > Collapse

Now this shortcut key will not work for you ! Unless you set it up using Tools > Options > Keyboard.

The command name is ReSharper_CollapseInSolutionExplorer.

Search using this command name and assign a shortcut key of your choice.

Options > Keyboard > ReSharper_CollapseInSolutionExplorer

and you now have a shortcut key ready to use to collapse all items in your solution explorer.

I know I am a little late to this discussion, but this surely gonna help some one or other.

Solution 7 - .Net

There's a macro at http://geekswithblogs.net/scottkuhl/archive/2007/04/09/111195.aspx for Visual Studio 2005.

Solution 8 - .Net

The VisualStudio extension CodeMaid provides collapsing.

Download from VisualStudioGallery.

The current version only supports VS2010 or higher, but you can install older versions side-by-side.

Solution 9 - .Net

Using Visual Studio 2017 and above

use shortcut

  • Open Tools > Options or press Alt + T + O
  • Under Environment tab > Keyboard (Also, you can create a shortcut for Tools.CustomizeKeyboard to open it directly)

To Collapse All

  • Search for "SolutionExplorer.CollapseAll"
  • Add a new shortcut for example Ctrl+Left Arrow,Ctrl+Left Arrow

To Expand All

  • Search for "SolutionExplorer.Folder.CollapseAll"
  • Add a new shortcut for example Ctrl+Right Arrow,Ctrl+Right Arrow

enter image description here

  • Assign > OK

Solution 10 - .Net

Visual Studio 2012 is out on 8/15/2012, so I suggest upgrading to that to get a fast "Collapse All" toolbar button previously available only in the Productivity Power Tools' Solution Navigator, which was sometimes too slow to be usable.

Solution 11 - .Net

Solution 12 - .Net

Use the Visual Studio extension that fits your version of Visual Studio. In my case (I use Visual Studio 2012) I use the extension Productivity Power Tools, but, unfortunately this exist only for VS 2010 and latter... For VS 2008 there is a similar extension: Power Commands.

Solution 13 - .Net

Delete the *.suo and *.csproj.user files, and reopen the solution/projects.

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
QuestionCleitonView Question on Stackoverflow
Solution 1 - .NetSebastian PattenView Answer on Stackoverflow
Solution 2 - .NetPeteView Answer on Stackoverflow
Solution 3 - .NetHuBeZaView Answer on Stackoverflow
Solution 4 - .NetAL.View Answer on Stackoverflow
Solution 5 - .NetAlan SimpsonView Answer on Stackoverflow
Solution 6 - .NetYasser ShaikhView Answer on Stackoverflow
Solution 7 - .NetTLiebeView Answer on Stackoverflow
Solution 8 - .NetEm1View Answer on Stackoverflow
Solution 9 - .NetAnas AlweishView Answer on Stackoverflow
Solution 10 - .NetPatrick SzalapskiView Answer on Stackoverflow
Solution 11 - .NetDMSQLOView Answer on Stackoverflow
Solution 12 - .NetsergeView Answer on Stackoverflow
Solution 13 - .NetCecil Has a NameView Answer on Stackoverflow