A custom folding extension for Visual Studio Code that offers enhanced control over code folding with features like instant collapsing and customizable fold markers.
Features
1. Normal Collapse
Collapses code sections marked by user-defined startFoldingMarker and endFoldingMarker.
Enabled by default, this feature allows code folding for specified markers, making it easier to manage sections in large files.
Customizable through the settings.
2. Instant Collapse
Collapses code from the instantCollapseMarker to 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.
3. Toggle Custom Folding (Keybinding: Ctrl+. for Toggle All/Selected, Ctrl+A to Toggle All)
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.
Provides a single, easy-to-use toggle functionality that adapts based on selection, improving usability and flexibility for managing large sections of code.
4. Toggleable Settings
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.
5. Transparent Color Coding (Optional)
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.
Extension Settings
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.
Usage
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.