How do I collapse sections of code in Visual Studio Code for Windows?

Nick picture Nick · May 6, 2015 · Viewed 463.5k times · Source

How do I fold or collapse sections of code in Visual Studio Code?

Is this feature supported?

Answer

Brocco picture Brocco · May 6, 2015

Folding has been rolled out and is now implemented since Visual Studio Code version 0.10.11. There are these keyboard shortcuts available:

  • 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 => 0) (zero) on Windows and Linux
    • + (K => 0) (zero) on macOS
  • Unfold All unfolds all regions in the editor:

    • Ctrl + (K => J) on Windows and Linux
    • + (K => J) on macOS

References: https://code.visualstudio.com/docs/getstarted/keybindings