Trying to find the equivalent to Ctrl + Shift + - in Intellij that collapses/expands all functions.
Asked
Active
Viewed 2.2e+01k times
263
-
3Possible duplicate of [How do I collapse sections of code in Visual Studio Code for Windows](http://stackoverflow.com/questions/30067767/how-do-i-collapse-sections-of-code-in-visual-studio-code-for-windows) – Jevgeni Geurtsen Sep 27 '16 at 07:29
-
Collapse all `Ctrl+K Ctrl+J` for someone in hurry. – Rajesh Swarnkar Jun 30 '23 at 07:59
5 Answers
458
Here it is.
Ctrl+Shift+[ Fold (collapse) region editor.fold
Ctrl+Shift+] Unfold (uncollapse) region editor.unfold
Ctrl+K Ctrl+[ Fold (collapse) all subregions editor.foldRecursively
Ctrl+K Ctrl+] Unfold (uncollapse) all subregions editor.unfoldRecursively
Ctrl+K Ctrl+0 Fold (collapse) all regions editor.foldAll
Ctrl+K Ctrl+J Unfold (uncollapse) all regions
Take Look at Visual studio Code Keybindings section at this link.
Also Platform specific Key board shortcuts available in pdf.here is the links

Jagadeesh Govindaraj
- 6,977
- 6
- 32
- 52
-
5This may have a conflict with the Vim plugin. Mentioning in case folks come here and scratch their head why it seems not to work. The Vim plugin is extremely bad about Ctrl-key sequences and MSoft could care less. – jatal Jun 02 '18 at 23:16
-
-
1Nice, and for Mac users, all same, just in place of `Ctrl` use `⌘ (Command)` – Hari Kishore Jun 03 '21 at 12:55
-
9Yes, it makes sense to make Ctrl+K+zero and Ctrl+K+J a pair of commonly used key bindings. Very wise to make them completely forgettable and bizarre. Well done Microsoft. Looking forward to not being able to install Windows 11. – Dan Rayson Jun 29 '21 at 13:47
46
You can set custom values for that.
- Open the Command Palette (⌘ + ⇧ + P or F1 on Mac)
- Search
Open Keyboard Shortcuts
- Then search for
collapse
- Finally click the + sign near the
Collapse All
andCollapse Folders in Explorer
options and set the shortcuts like I did
Or you can open keybindings.json
file and add this to the main array.
,
{
"key": "cmd+k cmd+s",
"command": "search.action.collapseSearchResults"
},
{
"key": "cmd+k cmd+e",
"command": "workbench.files.action.collapseExplorerFolders"
}

Nordle
- 2,915
- 3
- 16
- 34

Ahmad Awais
- 33,440
- 5
- 74
- 56
31
Go to File --> Preferences --> Keyboard Shortcuts (or Ctrl+K Ctrl+S)
Search for the word fold all
The ones you need are:
- Fold All
- Unfold All
Set your custom keyboard shortcut

Stefanos Kargas
- 10,547
- 22
- 76
- 101
19
One simple way I use is:
- Launch command pallete with Ctrl + Shift + P
- Search for
Collapse Folders in Explorer
- Press Enter
You can also define a custom shortcut for this command in settings.

Luis Felipe
- 191
- 1
- 4
-
Thanks this was helpful, a recent update has made all of my folders expand when I first open VS Code, which is less than ideal. This makes it easy to close them all. – Karl Carpenter Oct 14 '21 at 13:01
-
what about expand. Apparently for explorer, the feature is no more there. – Mohamed Allal Aug 23 '22 at 14:30
5
Go to 'Keyboard Shortcuts' and type in search input: "fold all regions". You see fold/unfold (expand/collapse) commands and shortcuts. Use or change them.

Alexander
- 51
- 1
- 3