michali
michali

Reputation: 3842

Visual studio code - keyboard shortcuts - expand/collapse all

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

Upvotes: 325

Views: 325629

Answers (6)

Jagadeesh Govindaraj
Jagadeesh Govindaraj

Reputation: 8285

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
Ctrl+K Ctrl+1   Fold Level 1 (2 for level 2, 3 for level 3 and so on)

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

Upvotes: 587

Ahmad Awais
Ahmad Awais

Reputation: 37100

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

Or you can open keybindings.json file and add this to the main array.

{
  // other key bindings ...
  {
    "key": "cmd+k cmd+s",
    "command": "search.action.collapseSearchResults"
  },
  {
    "key": "cmd+k cmd+e",
    "command": "workbench.files.action.collapseExplorerFolders"
  }
}

Upvotes: 50

Muhammad Ali
Muhammad Ali

Reputation: 101

Folding functionality has was introduced and fully integrated starting from Visual Studio Code version 0.10.11. Below are the available keyboard shortcuts for folding:

Fold folds the innermost uncollapsed region at the cursor:

  • Ctrl + Shift + [ on Windows and Linux
  • ⌥ + ⌘ + [ on macOS

Unfold unfolds the collapsed region at the cursor:

  • Ctrl + Shift + ] on Windows and Linux
  • ⌥ + ⌘ + ] on macOS

Fold All folds all regions in the editor:

  • Ctrl + K, Ctrl + 0 (zero) on Windows and Linux
  • ⌘ + K, ⌘ +0 (zero) on macOS

Unfold All unfolds all regions in the editor:

  • Ctrl + K, Ctrl + J on Windows and Linux
  • ⌘ + K, ⌘ + J on macOS

Upvotes: 5

Alexander
Alexander

Reputation: 71

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.

Upvotes: 5

Luis Felipe
Luis Felipe

Reputation: 251

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.

Upvotes: 25

Stefanos Kargas
Stefanos Kargas

Reputation: 11053

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

Upvotes: 42

Related Questions