A custom folding extension for Visual Studio Code that offers enhanced control over code folding with features like instant collapsing and customizable fold markers.
- Collapses code sections marked by user-defined startFoldingMarkerandendFoldingMarker.
- Enabled by default, this feature allows code folding for specified markers, making it easier to manage sections in large files.
- Customizable through the settings.
- Collapses code from the instantCollapseMarkerto the next empty line.
- If a normal collapse section is encountered before an empty line, it will include the normal collapse within the instant collapse.
- Configurable via settings to turn on/off as needed.
- Single Toggle Command: The toggle command can either toggle all collapsible ranges or only those within a selected region:
- Toggle All: If no text is selected, pressing Ctrl+.will toggle all collapsible ranges (fold/unfold) in the document.
- Toggle Selected: If a portion of text is selected, only the collapsible ranges within that selection will be toggled.
 
- Toggle All: If no text is selected, pressing 
- Provides a single, easy-to-use toggle functionality that adapts based on selection, improving usability and flexibility for managing large sections of code.
- Enable Normal Collapse: Allows you to turn on or off the normal collapse feature without reloading.
- Enable Instant Collapse: Instantly toggle the instant collapse feature.
- Enable All Features: A master setting to enable or disable all custom folding features.
- Each folding section (start and end lines) can be colorized with a transparent color to visually distinguish different code blocks.
- Random colors are assigned to pairs of markers to maintain clarity in the code structure.
- Adjust the transparency so that text remains clearly visible.
This extension contributes the following settings:
- customFolding.startFoldingMarker: Specifies the marker to begin a normal collapse section (default:- // <).
- customFolding.endFoldingMarker: Specifies the marker to end a normal collapse section (default:- // >).
- customFolding.instantCollapseMarker: Defines the marker for instant collapse (default:- // >>).
- customFolding.enableNormalCollapse: Enables/disables the normal collapse feature.
- customFolding.enableInstantCollapse: Enables/disables the instant collapse feature.
- customFolding.enableAllFeatures: A master toggle to turn on/off all custom folding features.
- Add the start and end markers in your code where you want collapsible sections.
- Adjust the settings in your VS Code settings to customize the markers and enable/disable features.
- Use the toggle command (Ctrl+.) to collapse/unfold all ranges or only selected ranges, depending on whether text is selected.
- The extension will automatically apply folding and color coding based on your settings.
- Download the extension from the Visual Studio Code Marketplace.
- Open VS Code and go to Extensions (Ctrl+Shift+X).
- Search for "Custom Folding Extension" and click "Install."
Feel free to open issues and submit pull requests to improve this extension.
MIT.