263

Trying to find the equivalent to Ctrl + Shift + - in Intellij that collapses/expands all functions.

Penny Liu
  • 15,447
  • 5
  • 79
  • 98
michali
  • 3,230
  • 4
  • 18
  • 20

5 Answers5

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

Windows,MAC,Linux

Jagadeesh Govindaraj
  • 6,977
  • 6
  • 32
  • 52
  • 5
    This 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
  • Ctrl + K Ctrl + 3 – noririco Jul 27 '20 at 05:18
  • 1
    Nice, and for Mac users, all same, just in place of `Ctrl` use `⌘ (Command)` – Hari Kishore Jun 03 '21 at 12:55
  • 9
    Yes, 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.

  1. Open the Command Palette ( + + P or F1 on Mac)
  2. Search Open Keyboard Shortcuts
  3. Then search for collapse
  4. Finally click the + sign near the Collapse All and Collapse Folders in Explorer options and set the shortcuts like I did

keyboard vscode collapse all shortcuts

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:

  1. Launch command pallete with Ctrl + Shift + P
  2. Search for Collapse Folders in Explorer
  3. Press Enter

You can also define a custom shortcut for this command in settings.

Luis Felipe
  • 191
  • 1
  • 4
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