Etsi0 / class-collapse

This powerful extension lets you collapse any code segment using custom regex patterns. Simplify your coding view, enhancing readability and focus.
https://marketplace.visualstudio.com/items?itemName=Etsi0.class-collapse
MIT License
8 stars 0 forks source link
ts typescript vscode vscode-extension
icon of extension

Class Collapse

TLDR

Class Collapse enhances your coding experience by mimicking VS Code's collapsing feature. This tool becomes essential when dealing with frameworks such as Tailwind CSS, known for their extensive usage of utility classes that can often make your code less readable. Class Collapse uses regex (can be customized inside settings) to make your coding experience cleaner by collapsing segments of your code, making it significantly easier to read and navigate.

ko-fi discord

Features

To toggle the Class Collapse extension, open the Command Palette with Shift+Ctrl+P, search for Class Collapse: Toggle Collapsing, or use the shortcut Alt+Ctrl+Shift+C. This key combination is chosen to avoid overriding any default bindings and avoid accidental activations or deactivations, with C also representing Class Collapse.

How to open a collapse

Opening a collapse is as easy as clicking or selecting the collapse, making them only expanded when needed. Gif that selects code to show how to looks when collapses gets expanded

Customization

This extension is highly customizable, allowing you to make it feel and look exactly how you want it; if something is missing and you want me to add it, please create an issue on my GitHub repo and I will consider your request.

Inspired by Inline fold, which has stopped receiving updates; more information on why is available on their GitHub repo

Extension Settings

Example:

{
    "enable": true,
    "diffEditor": true,
    "openCollapseOnLineSelected": true,

    "regex": "(class|className)(?:=|:|:\\s)((['\"])([\\s\\S]*?)\\3|{\\s*((['\"`])([\\s\\S]*?)\\6|(?!['\"`])([\\s\\S]*?))\\s*})",
    "regexFlags": "g",
    "regexGroups": [4, 7, 8],

    "placeholderText": "...",
    "placeholderTextColor": "#C3E88DFF",
    "openCollapseOpacity": 1,

    // https://code.visualstudio.com/docs/languages/identifiers#_known-language-identifiers
    "supportedLanguages": [
        "astro",
        "html",
        "javascriptreact",
        "javascript",
        "markdown",
        "php",
        "svelte",
        "typescript",
        "typescriptreact",
        "vue",
        "vue-html"
    ]
}

Available Settings:

Functionality

Regex

Whitelist

Style

Languages

Known Issues

Create an issue on the extension's GitHub page. If you have any troubles

Release Notes

Check out the release notes at https://github.com/Etsi0/class-collapse/releases

Contributors

Everyone that has contributed to this project