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.

- 25,472
- 25
- 109
- 197

- 17,663
- 13
- 46
- 59
-
24FYI, * is the expand-all key (This doesn't answer the question but is related.) – Sprague Nov 09 '12 at 09:46
-
NOTE: built-in to VS 2012 and 2013 - read down for details – Andy Nov 30 '15 at 09:59
-
1@Sprague \* only works with the dedicated key on the numeric keypad. How do you expand all, in the absence of a numeric keypad? – Marco Lackovic Apr 26 '16 at 07:31
-
@Marco Lackovic (late reply) My best bet is to search "expandall" in Tool>Option>Environment>Keyboard and set a hotkey. (didn't test) – javaLover Mar 25 '17 at 03:29
14 Answers

- 7,157
- 4
- 45
- 51
-
13
-
7@RayLoveless no but you can set one in Tools -> Options -> Environment -> Keyboard – Adam Short Feb 29 '16 at 10:33
-
6@AdamShort I found it convenient to assign action "Collapse All" to "Num /" key, it makes a good match for the "Num *" (Expand All) – Varvara Kalinina May 24 '17 at 09:06
-
1@VarvaraKalinina How did you do that? `SolutionExplorer.CollapseAll`will only accept CTRL+something, trying to just use `\` does nothing for me – Noctis May 22 '18 at 06:29
-
The CTRL key requirement only exists at global scope. Under the "Use new shortcut in:" set it to something more specific -- Solution Explorer would make the most sense. – Reticulated Spline Oct 04 '21 at 18:20
If you have ReSharper installed, you can right click on the solution in the solution explorer, and select "Collapse All".

- 12,206
- 8
- 54
- 70
-
Thanks Pete! I didn't know resharper did this either. Especially after hitting "*" by accident. – ThisGuyKnowsCode Jul 12 '11 at 14:36
-
1Request clarification or suggest improvement. Using resharper - what is the command / shortcut? – Mars Robertson Jul 23 '13 at 15:13
You can use PowerCommands for Visual Studio 2008
Right click on the project\solution on the solution explorer and choose Collapse Project:

- 21,988
- 13
- 81
- 109

- 4,715
- 3
- 36
- 58
-
1
-
I tryed to use it, but after it was installed on my machine, my vs2008 stopped to work. LOL – Cleiton Aug 31 '09 at 14:53
-
@Chris: I never tried it (I actually use the undo close window), but under Tools\Options\PowerCommands\Commands you can disable any feature you want. – HuBeZa Aug 31 '09 at 14:56
-
-
1Power Commands doesn't collapse solution folders either and instead expands them randomly – Mario Jan 07 '13 at 22:52
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.
-
3Unfortunately this only collapses/expands the current node (just like clicking on the expand/collapse icon), not any children, which I don't think is a solution for the OP: for instance if you have 3 projects, each with 2 folders, each with 10 folders. Collapsing the solution as a whole is great, but when you expand it again you're back to a list of 60 items rather than a list of 3 projects. – DaveD Jun 15 '12 at 14:14
-
2
If you have Resharper installed, there is an option called Collapse All and a shortcut key next to it.
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.
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.

- 61
- 1
- 7

- 46,934
- 46
- 204
- 281
-
6It should be mentioned that this is not default VS functionality (pre 2012), but, in this instance, the additional context menu item and shortcut is provided by Resharper. – kodjeff1 Jul 30 '13 at 18:36
-
In VS2015 with ReSharper 2016.1 this is now just `CollapseInSolutionExplorer`. – absynce Jun 02 '16 at 16:19
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

- 2,818
- 4
- 30
- 44
-
Is it really correct? SolutionExplorer.Folder.CollapseAll to expand all? – M. Koch Mar 25 '23 at 10:50
There's a macro at Link for Visual Studio 2005.

- 21,988
- 13
- 81
- 109

- 7,913
- 1
- 23
- 28
-
-
go to Tools -> Macros -> Macro IDE, and paste the macro code in a module – Thomas Levesque Aug 31 '09 at 14:38
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.

- 8,738
- 11
- 67
- 129
take a look on this
http://visualstudiogallery.msdn.microsoft.com/en-us/7272073b-32d4-4a84-93f7-77d09fb16f01

- 19
- 1
It’s very simple now in visual studio 2022 17.7 version. It’s easier and more flexible.
When you right-click on a node in Solution Explorer. You can use this to collapse the selected node as well as its descendent nodes. We've also mapped this as a shortcut via the Ctrl+Left arrow keys.

- 25,472
- 25
- 109
- 197
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.

- 21,988
- 13
- 81
- 109

- 13,940
- 35
- 121
- 205
-
-
Go to Tools => Extensions in Visual Studio and Install the specified add-ins to have the desired functionnality. – serge Sep 17 '13 at 16:12
Delete the *.suo
and *.csproj.user
files, and reopen the solution/projects.

- 4,962
- 1
- 29
- 31
-
-
2It will compile, but you will loose currently opened tabs, startup projects (painful if you have multiple), as well as other per-user settings. – Dav Nov 22 '12 at 08:55