Last updated on
Fold Code in VS Code to Read Big Files Easier
A quick VS Code tip for folding all the code in a file so you can understand its structure, using only the keyboard.
Watch the video
Loading this video connects you to YouTube (Google), which receives your IP address and may store or read information on your device for playback and advertising. YouTube may show ads. Choose Load YouTube video to allow this for this video. See Google's privacy policy.
Watch Fold Code in VS Code to Read Big Files Easier on YouTube
Fold and unfold with the keyboard
I'm a blind developer, so when I open a large file I can't just scan through it quickly. One thing that helps a lot in VS Code is folding the code so I can understand the file's structure first.
To collapse everything, press Ctrl+K, then Ctrl+0. That folds all the classes, functions, and methods before I dig into any one part.
To expand it all back out, press Ctrl+K, then Ctrl+J.
No mouse needed.
Open one section at a time
With everything folded, arrow down through the file and you only hear the top line of each class or function. When you find the one you want, press Ctrl+Shift+] on that line to unfold just that section, and Ctrl+Shift+[ to fold it again when you are done.
If you already know the file name, open it fast with Ctrl+P first.