22

Like I said in the title of this question, is it possible to attach a keyboard shortcut to collapse all items in the solution explorer with Visual Studio 2012?

In previous version; 2010, I was able to create a macro to enable this feature but in Visual Studio 2012, there is no more support for macros.

I'm able to right click onto item in the solution explorer and choose 'Collapse All' but I prefer to just typed 'Ctrl+Shift+C' to do the same job.

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
Samuel
  • 12,073
  • 5
  • 49
  • 71
  • Do you really see it in the context menu? If you do, you should be able to go to Tools --> Customize --> Commands --> Context menu and assign a keyboard shortcut. I see a 'collapse all' icon but I don't see it in the context menu, so I'm not able to assign a shortcut. – Johnny Oshika Oct 03 '12 at 05:07
  • Hi @Samuel, any success with this? I'm still looking for a solution to this. – Johnny Oshika Nov 08 '12 at 19:21
  • No @JohnnyO. :( Each time Microsoft release a new version of Visual Studio, some nice features are removed. Without Macros, it's hard to figure out how we can now implement this feature. – Samuel Nov 08 '12 at 22:23
  • Thanks @Samuel. I used Macros in VS 2010 as well. There are also extensions for VS 2010 that offer this capability as well, but I don't see anything for VS 2012. – Johnny Oshika Nov 09 '12 at 01:02
  • I found this link where you can use resharper to attach a shortcut key: http://yassershaikh.com/how-to-collapse-all-items-in-solution-explorer-in-visual-studio-with-resharper/ The problem is that the focus must be on an item in the solution explorer. – Samuel Nov 09 '12 at 02:00

5 Answers5

11

FWIW, this is the best I've been able to come up with so far.

Alternative 1

  1. Press Ctrl+¨ to put focus in the search box above the Solution Explorer.
  2. Press Shift+Tab to move focus to the toolbar.
  3. Use the left arrow to move focus to the left, until you hit the Collapse All button (four times. YMMV).

Alternative 2

  1. Press Ctrl+Alt+l (or whatever your personal shortcut is) to focus the Solution Explorer.
  2. Press Shift+Alt to focus the Solution Explorer toolbar. This puts the focus on the Home button on the toolbar.
  3. Use the right arrow to move focus to the right, until you hit the Collapse All button (three times).
  4. Press Enter.

Alternative 3

  1. Press Ctrl+Alt+l (or whatever your personal shortcut is) to focus the Solution Explorer.
  2. Press and hold the left arrow until you've reached the top node (the Solution node).
  3. Press the up arrow to put focus in the search box above the Solution Explorer.
  4. Press Shift+Tab to move focus to the toolbar.
  5. Use the left arrow to move focus to the left, until you hit the Collapse All button (two times. YMMV).
Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
  • 6
    +1 ahhhhhh, what will be the keyboard shortcuts sequences in visual studio 2014??? Ctrl+shift+. 3 times, turn around your computer, wait 10 second, kick your head on the desktop ! It seems we are just a couple of freak guys who use too much keyboard shortcuts. :) – Samuel May 09 '13 at 22:18
  • Alternative 2 still works in VS 2013. Shift+Tab doesn't work as expected in VS 2013. – Johnny Oshika Jan 25 '14 at 01:13
9

As you can see in the screenshot below, there is an option called Collapse All and a shortcut key next to it.

enter image description here

Now this shortcut key will not work for you !

Unless ofcourse, you set it up using Tools > Options > Keyboard. The command name is CollapseInSolutionExplorerAction. Search using this command name and assign a shortcut key of your choice.

enter image description here

That's it and you are ready to use your shortcut key !

Source

Yasser Shaikh
  • 46,934
  • 46
  • 204
  • 281
  • 4
    That's the ReSharper *collapse all* command. The OP asked about the Visual Studio 2012 button. – Mark Seemann Nov 09 '12 at 14:13
  • This screenshot looks like 2010 too. In 2012 there is a Collapse All button in Solution Explorer but I can't figure out what command it is mapped to – Mario Jan 07 '13 at 22:54
  • 2
    The new command is 'CollapseInSolutionExplorer' but it does not work as expected compared to previous versions of Visual Studio while using macros. The command only works if the desired node in the solution explorer is selected. In other words, if you have the focus in the code editor as example, the command will not work. It's better than nothing but you will have to make a manipulation of the mouse in all cases. – Samuel Jan 08 '13 at 14:39
  • 2
    I tried 'ctrl+alt+L' to make the focus on the solution explorer and then use the left arrow as many times required to set the focus on the root node of the solution explorer and then use the shortcut and you said to be sure that all nodes are collapsed. I don't know which features in VS 2014 will be removed ?! :( – Samuel Jan 08 '13 at 14:43
  • I had the same problem and Samuel's suggestion worked for me. Focus to Solution Explorer was different for me, Ctrl+Alt+1. Also, the ProjectAndSolutionContextMenus.Project.CollapseRecursively command seems to work no matter where I am focused in solution explorer. – Bryan Matthews Jan 16 '13 at 15:16
  • 2
    Correction. The command is ProjectAndSolutionContextMenus.Project.CollapseProjects. – Bryan Matthews Jan 16 '13 at 18:34
  • In VS 2013 I found `ProjectAndSolutionContextMenus.Project.PowerCommands.CollapseProjects` (note that I have Microsoft's Productivity Power Tools extension installed from NuGet so this may be coming from there) – jwatts1980 Oct 09 '14 at 20:53
1

Visual Studio 2012 / ReSharper 8.0.1:

The command is 'ProjectAndSolutionContextMenus.Project.ReSharper_CollapseInSolutionExplorer'.

1

I suggest you to try CodeMaid extension for Visual Studio. It provides a command "Collapse All Projects Recursively" that has customizable shortcut (by default, it is Ctrl+M,-). It has some other nice abilities, like switching between .cpp and its .h files, joining lines, etc.

lxgreen
  • 1,511
  • 15
  • 14
0

I have searched on the net a way to do this when I have first install VS2012 ..

I have just found the solution, so I share it :)

you can do this by adding your visual studio version to an existing Extension ...

  • Download the extension for VS 10
  • Change the extension from vsix to zip
  • extract it and open the file extension.vsixmanifest
  • Find this xml section : SupportedProducts Add this :

    <VisualStudio Version="11.0">
    <Edition>Ultimate</Edition>
    <Edition>Premium</Edition>
    <Edition>Pro</Edition>
    </VisualStudio>
    

you can also try version 12 for visual studio 2013 ...

  • zip it, and change the extension from zip to vsix.

  • Now you can Install it.

  • after install it, Goto Tools -> Customise and click on the keyboard button.

  • Search "CrossProjectMultiProject.CollapseProjects" and assing the shortcut you like.

Have a nice codding. Please +1 if this help you

ps. sorry for my bad English, im French ;-)

Benoit
  • 1,109
  • 14
  • 29