Vs Code one tip a week: code folding
Aurelio

Aurelio @aurelio

About: Engineering manager and software engineer in Zürich

Location:
Zürich
Joined:
Aug 16, 2018

Vs Code one tip a week: code folding

Publish Date: Jul 25 '19
63 4

Code folding can make browsing long files easier. When we're trying to focus on the big picture without being distracted by smaller details code folding can be an invaluable aid.


This is an effort to learn how to get the best out of Vs Code keyboard shortcuts without feeling overwhelmed.

Learning how to use our favourite IDE without a mouse can make a big difference.
Since an extension like the amazing Key Promoter for Jetbrains seems to be far from being a reality for now at least, I started collecting my favourite keyboard tricks in bite sized chunks.

The idea is simple: find one tip you like, practice it the whole week until you've really mastered it and made it part of your workflow and then move to the next one.


To fold a block

⌘ + OPTION + [
Enter fullscreen mode Exit fullscreen mode

To unfold it:

⌘ + OPTION + ]
Enter fullscreen mode Exit fullscreen mode

Users of Vs Code with Vim extensions

The above command will work for all users of VsCode. Those using a vim emulation extension like VsCodeVim or amVim will have an extra pair of shortcuts to choose from.

To fold a block, switch to normal mode and:

z + c
Enter fullscreen mode Exit fullscreen mode

Where "c" stands for "close".

To unfold:

z + o
Enter fullscreen mode Exit fullscreen mode

Where "o" stands for "open".

Further shortcuts

Note that you can also fold and unfold an entire file, but I find that less useful and never really felt the need to memorise that shortcut combination.

Resources

Originally published on my blog.

Comments 4 total

  • Daniel Hobson
    Daniel HobsonJul 26, 2019

    For Windows users:

    Fold:

      Ctrl + Shift + [
    

    Unfold:

      Ctrl + Shift + ]
    
    • Aurelio
      AurelioJul 26, 2019

      Nice! Thanks for adding it!

    • Anton Burov
      Anton BurovJul 27, 2019

      Thanks Daniel.
      I was surprized that the article doesn't contain an option for Windows, but contains one for vim extension, which makes it useless for the majority of users.

  • Carlos A.
    Carlos A.Jul 27, 2019

    Under openSuSE Leap 15.1 Linux, VS Code 1.36.1, keyboard Spanish Latinamerica

    to open

    Ctrl + {
    

    to close

    Ctrl + }
    
Add comment