Amir's Blog

2025-08-09 General

Folding code blocks in IDE

Folding code blocks in IDE

I mean, this time I don’t wanna write something technical, rather, I wanna talk about one recent hack I learned that saved me time and made my workflow more efficient. Often, when you work on large-scale projects, you can face some very, very large codebases, and individual modules may have a couple thousand lines. Before, I didn’t know what I’m about to share, and it was a pain for me to try to find what I wanted in the most efficient way 🙄. That’s why I’m writing this blog.

One thing that can help when navigating such files is having all the code blocks folded. It helps you get back to the original root of the function, class, or top elements of what you’re working with, and understand how the flow of the code execution starts. Your eyes can follow what’s happening instead of just seeing line after line.

To do that, I found a cool command that can help. At the time of this blog, VS Code is still alive 🔜🪦, so let’s look at how it works in VS Code (Windows)

// Fold all
Ctrl + K, Ctrl + 0
// Unfold all
Ctrl + K, Ctrl + J
  • keep in mind that it does not work with the 0 in the touch pad, use the number row on the top of alphabet In case you are using cursour for your day to day jon , you know that the key combination ctrl+k is reserved for other purposes, so you can simply use another key combination to do so
// Fold all
Ctrl + M, Ctrl + 0
// Unfold all
Ctrl + M, Ctrl + J

It may be a different combination on your computer, so you can check it by:

ctrl + shift + p

to find all your shortcuts or change them.

That’s all. Chao 🍻