When I collapse a folder, I want the sub-folder to be collapsed as well. Right now when I collapse a folder and re-open it, the sub-folders stay as they were while the folder was being closed. I want the behaviour where collapsing the folder also collapses the sub-folders.
How to Collapse All Folders in VS Code? To fold all the folders in your code: Enter command >fold and hit enter.
Expand/collapse folders icons to expand or collapse a selected folder. Right-click a folder and choose Expand > Folder or Collapse > Folder to expand/collapse the selected folder. Right-click a folder and choose Expand > Expand All or Collapse > Collapse All to expand or collapse the entire tree.
Or use keyboard shortcuts: How to Collapse All Folders in VS Code? To fold all the folders in your code: Enter command >fold and hit enter. Or use keyboard shortcuts: To unfold all the folders in your code: Enter command >unfold all and hit enter. Or use keyboard shortcuts: How to Collapse All Regions in VS Code?
Open the Keyboard Shortcut by pressing Ctrl + K then Ctrl + S and search for Collapse, you will see the Collapse Folders in Explorer key binding (It is empty by default). Press the + button to add your desired key binding.
This feature is now supported, since Visual Studio Code 1.17. To fold/collapse your code block, just add the region tags, such as //#region my block name and //#endregion if coding in TypeScript/JavaScript.
To unfold all the regions in your code: Enter command >unfold all and hit enter. Or use keyboard shortcuts: How to Collapse All XML Nodes in VS Code? To fold all the XML nodes in your code: Enter command >fold and hit enter. Or use keyboard shortcuts:
You can Alt+Click a folder to recursively expand or collapse it. However, I don't think it's possible to make that the default, since keybindings don't support mouse input.
The new 1.42 (Q1 2020) VSCode might help:
Two-step collapse in multi-root Explorer
When you are using a multi-root workspace, the Collapse Folder button in the File Explorer now has a two-step behavior, where:
- the first click will collapse all folders within each top-level, and
- the second click will collapse the top-level folders.
The Search view already has this behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With