Reputation: 1151
Can you anyone provide the shortcut for collapse all files in visual studio code explorer?
Upvotes: 85
Views: 37414
Reputation: 1280
The below solution:
Solution:
Upvotes: 9
Reputation: 8951
First, click anywhere in the explorer window to activate it, then use the shortcut.
On Windows and Linux.
Ctrl + Left arrow
On Mac:
⌘ + Left arrow
Upvotes: 18
Reputation: 1734
When the Explorer is active, you could use the Workbench list
based shortcuts. list
based shortcuts include collapse, collapse all, expand, expand all, toggle expand/collapse
To see what are the shortcuts open Keyboard Shorcuts
-> Search for list.
. Here you find shortcuts for collapse, collapse all, expand, expand all, toggle expand/collapse. These shortcuts work when the Explorer is active, as the Explorer works as a list.
Below is a screenshot for Mac.
If you would like to define a shortcut, without activating the Explorer, then I would recommend - cmd+k ctrl+c
. You could add this by opening Keyboard Shorcuts
-> Search for Collapse Folders in Explorer
-> Click the edit button after hovering over the the Command you want to edit.
Upvotes: 2
Reputation: 2475
I personally prefer not to create new shortcuts. As @Mark pointed out on the answer of @JayChase there is an existing shortcut, but it requires the explorer to be in focus. Therefore I combine the shortcut mentioned by @JayChase with another standard shortcut, to get the desired behaviour.
command + 0
(focusses on explorer).command + left-arrow
An additional benefit over this approach is that I usually want to focus on the explorer view if I want to collapse the folders.
Upvotes: 123
Reputation: 1403
Open the Keyboard Shortcut
by pressing Ctrl + K
then Ctrl + S
and search for Collapse
, you will see the Collapse Folders in Explorer
key binding (It is empty by default). Press the + button to add your desired key binding.
Now you can enjoy your shortcut.
Upvotes: 89