Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

Is this feature supported?

like image 959
Nick Avatar asked May 06 '15 04:05

Nick


People also ask

How do you make collapsible sections in VSCode?

In VSCode terminology, the collapsible code blocks feature is called Fold/Unfold. You can quickly fold a block of code, given that your cursor is placed inside of it by pressing Ctrl+Shift+[ keyboard combination. Similar to that, Ctrl+Shift+] key combination will unfold the collapsed region at the cursor.

How do I collapse all sections in Visual Studio?

(Ctrl+M, Ctrl+P) - Removes all outlining information for the entire document. (Ctrl+M, Ctrl+U) - Removes the outlining information for the currently selected user-defined region. Not available in Visual Basic. (Ctrl+M, Ctrl+O) - Collapses the members of all types.


1 Answers

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

like image 135
Brocco Avatar answered Sep 28 '22 10:09

Brocco