Smart Fold Toggle adds a small button to the right side of the VS Code status bar:
- Smart Fold chooses a useful outline depth and folds at that level.
- Expand All unfolds every region in the active editor.
It uses VS Code's built-in folding commands and never edits or saves your files.
Smart depth
The extension uses the document outline supplied by the current language:
- Files containing ordinary top-level functions fold at level 1.
- Files made of one or more classes fold at level 2, exposing their methods.
- Wrapper structures such as a namespace containing classes can fold at level 3.
- Folding is always capped at level 3, so it does not descend through nested implementation details.
If a language does not provide an outline, the extension safely falls back to level 1.
Usage
- Open a file that supports code folding.
- Click Smart Fold in the status bar.
- Click Expand All to restore the full editor view.
The same actions are available from the Command Palette:
Smart Fold Toggle: Toggle Smart FoldingSmart Fold Toggle: Smart FoldSmart Fold Toggle: Expand All
Notes
Folding and outline symbols are provided by VS Code and the language extension for the current file, so exact behavior can vary by language. VS Code does not expose the current folding state to extensions; the button reflects the most recent action performed by this extension for each open file.
Development
pnpm install
pnpm check
Press F5 in VS Code to launch an Extension Development Host.