Visual studio code - keyboard shortcuts - expand/collapse all

Visual Studio-Code

Visual Studio-Code Problem Overview


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

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

Here it is.

Ctrl+Shift+[	Fold (collapse) region	editor.foldCtrl+Shift+]	Unfold (uncollapse) region	editor.unfold
Ctrl+K Ctrl+[	Fold (collapse) all subregions	editor.foldRecursivelyCtrl+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

Solution 2 - Visual Studio-Code

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"
  }

Solution 3 - Visual Studio-Code

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

Solution 4 - Visual Studio-Code

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.

Solution 5 - Visual Studio-Code

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmichaliView Question on Stackoverflow
Solution 1 - Visual Studio-CodeJagadeesh GovindarajView Answer on Stackoverflow
Solution 2 - Visual Studio-CodeAhmad AwaisView Answer on Stackoverflow
Solution 3 - Visual Studio-CodeStefanos KargasView Answer on Stackoverflow
Solution 4 - Visual Studio-CodeLuis FelipeView Answer on Stackoverflow
Solution 5 - Visual Studio-CodeAlexanderView Answer on Stackoverflow