'Visual Studio Code - Shortcut - Collapse all files in explorer

Can you anyone provide the shortcut for collapse all files in visual studio code explorer?



Solution 1:[1]

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.

Solution 2:[2]

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.

Solution 3:[3]

it's cmd/ctrl + shift + up-arrow

Solution 4:[4]

You can collapse all folders using cmd/ctrl left-arrow.

Solution 5:[5]

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

Solution 6:[6]

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. Collapse shortcuts for list

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Thanh Le Hai Hoang
Solution 2 Fluous
Solution 3 ahhmarr
Solution 4 JayChase
Solution 5 Mwiza
Solution 6 Libin Varghese