Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Collapse Inactive FoldersNew to Visual Studio Code? Get it now.
Collapse Inactive Folders

Collapse Inactive Folders

VastBlast

|
1 install
| (1) | Free
Collapse inactive Explorer folders while keeping the focused item and its path expanded.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Collapse Inactive Folders

Collapse Explorer folders without losing the item you are working on.

The extension adds a distinct Collapse Inactive Folders button beside VS Code's built-in Explorer controls. It collapses the tree completely—including inactive top-level folders in multi-root workspaces—then restores the focused item and its path.

Usage

  1. Focus a file or folder in the Explorer, or keep working in a file-backed editor.
  2. Click Collapse Inactive Folders in the Explorer title bar.

If the Explorer had focus, its focused row remains selected; a focused folder is reopened as well as its parent path. If an editor had focus, the active file becomes the preserved item. The same action is available from the Command Palette and the Explorer context menu. Context-menu use preserves every selected file or folder and leaves the clicked item focused.

Settings

Setting Default Description
collapseInactiveFolders.preserveFocusedItem true Preserve the item that had focus when the command started. Disable it to collapse everything. Explicit Explorer context-menu targets are always preserved.

Behavior and compatibility

  • In multi-root workspaces, inactive workspace roots collapse too; only roots containing a preserved item reopen.
  • A protected folder stays open, but unprotected expansion state below it is intentionally collapsed.
  • The title button and Command Palette preserve one focused item. Use the Explorer context menu to preserve a multi-selection.
  • Resources outside the current workspace and resource-less tabs such as terminals and webviews are ignored.
  • Multi-root workspaces, compact folders, local folders, WSL, Dev Containers, SSH, and other remote or virtual workspace providers use the same URI-based behavior.
  • No operating-system paths are parsed or normalized by the extension. VS Code owns workspace matching and Explorer reveal behavior, avoiding drive-letter, separator, UNC, and remote-authority inconsistencies.
  • Rapid follow-up invocations retain the latest target instead of being discarded.
  • VS Code Desktop on Windows, macOS, and Linux is supported, including remote desktop workflows. Standalone VS Code for the Web hosts are not currently supported.

Installation

Install Collapse Inactive Folders from the Visual Studio Marketplace, or run:

code --install-extension VastBlast.vscode-collapse-inactive-folders

Development

npm install
npm test
npm run package

Press F5 in VS Code to open an Extension Development Host. Publishing uses npm run publish after updating the version and changelog.

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft