Collapse code blocks in VS Code
// Collapse the actual code block
CTRL + SHIFT + [
// Collapse ALL
CTRL + K CTRL + 0
In Visual Studio Code, there are several options for collapsing and expanding or, as is more often used folding and unfolding code blocks.
You can fold and unfold blocks using your mouse and click on the related small arrow icons on the gutter.
A more common way is to use keyboard shortcuts. To fold the actual code block use the CTRL + SHIFT + [
to unfold it use CTRL + SHIFT + ]
. Note that this combination depends on your language preferences and keyboard layout. To check the actual shortcut press F1
and type fold. You will get all folding-related options with the actual shortcut.
To collapse all use the CTRL + K
CTRL + 0
. Note that 0
on Numpad is not working, only the 0
from the main keyboard area works.
You can also collapse on a specified level. For example, use CTRL + K
CTRL + 2
to easily see the methods of a Java class.
More folding options:
- Fold
- Fold All
- Fold All Block Comments
- Fold All Regions
- Fold All Regions Except Selected
- Fold Level 1
- Fold Level 2
- Fold Level 3
- Fold Level 4
- Fold Level 5
- Fold Level 6
- Fold Level 7
- Fold Recursively
- Fix: Prettier stopped working in VS Code
- Split editor window in VS Code
- Change default terminal in VS Code
- Wrap selection with tag in VS Code
- Edit multiple lines at once in VS Code
- Make text uppercase in VS Code
- Associate file type in VS Code
- Change syntax highlighting in VS Code
- Search for file in VS Code
- Add vertical rulers in VS Code
- Change indentation in VS Code
- Collapse code blocks in VS Code
- Open files always in a new tab in VS Code
- Delete line without selection in VS Code
- Jump to closing bracket in VS Code
- Select all occurrences of selected word in VS Code
- Change font size in VS Code
- Toggle minimap in VS Code
- Change colors in VS Code integrated terminal
- Change file encoding in VS Code
- Disable tooltip in VS Code
- Move the sidebar panel to the right in VS Code
- Export VS Code extensions
- Toggle word wrap in VS Code
- Exclude folders from search in VS Code
- Get multiple cursors in VS Code
- Show hidden characters in VS Code
- Remove trailing spaces in VS Code
- Go back to last edited position in VS Code
- Switch between terminal and editor in VS Code
- Open VS Code with the current folder from terminal
- Navigate back to last cursor position in VS Code
- Change terminal font size in VS Code
- Duplicate line or selection in VS Code
- Format code in VS Code
- Compare two files in VS Code
- Comment out multiple lines in VSCode
- Go to line in VS Code
- Move line up or down in VS Code