Structure FoldA VS Code extension that folds Python and C++ definitions, not arbitrary indentation levels. Three levels
Minus moves Only the active editor is affected. Each open file/editor group has an independent level, including split views. Levels survive tab switches, and active editors retain their level when moved. Levels are not persisted across closing the document or restarting VS Code. Named nested definitions, decorated/async Python functions, Python property getters, and C++ constructors, destructors, and overloaded operators are included. One-line definitions and C++ declarations without bodies are left alone. Loops, conditionals, fields, multiline values, comments, imports, namespaces, enums, and lambda expressions are not targeted. Existing manual folds of those regions are preserved. Level 0 expands definitions; it does not restore an earlier set of manual class/function folds. Source text is never edited. InstallInstall Structure Fold (
For manual installation, choose Extensions -> ... -> Install from VSIX...
and select If you installed an earlier local build, uninstall
Enable Settings Sync: Extensions in VS Code to synchronize installation across your machines. Python/C++ language support is still required on each host. The extension requires VS Code 1.96 or newer and language support that supplies document symbols and compatible folding ranges:
C++ headers are supported when their VS Code language mode is C++. Read-only editors are supported because folding does not change the document. Shortcuts
On a US keyboard, the plus binding is To change either shortcut, open Preferences: Open Keyboard Shortcuts, search for Structure Fold, and edit:
Both commands are also available in the Command Palette. The default shortcuts
are active only while a Python/C++ text editor has focus, so ordinary typing of
Manual folding clicks do not change the remembered level. The next shortcut applies the requested level again. Diagnostics and limitationsProvider failures and unavailable symbols/ranges are reported in a notification and the Structure Fold output channel. Wait for the language service to load and ensure Editor: Folding is enabled. The commands serialize rapid key presses and cancel stale work when the active file/editor group, document, language mode, or folding settings change during a request. Recreating the editor for the same document in the same group does not cancel folding. VS Code folding is line-based. Definitions must have distinct folding headers to represent level 1 independently. Ambiguous/shared headers or incomplete provider ranges produce an error instead of folding a class or an internal block by accident. For very large files, also check Editor: Folding Maximum Regions. Both clangd's region-labelled folds (which leave closing braces visible) and Microsoft C/C++ folding ranges are supported. Python folds may include trailing indented comments beyond the language provider's symbol range; these remain part of the whole-definition fold. Development and verificationNode.js 22 or newer is required for the development/packaging tools. There are no runtime npm dependencies.
The integration tests use a separate VS Code 1.96.4 Extension Development Host,
original Python/C++ fixtures, and an isolated user profile. The provider smoke
tests install Python/Pylance and C/C++ only into a test extension directory.
Use Headless Linux/WSL testing can use the supplied
Keep |