All Projects → zokugun → vscode-explicit-folding

zokugun / vscode-explicit-folding

Licence: MIT License
Customize your Folding for Visual Studio Code

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to vscode-explicit-folding

vscode-theme-by-language
A VS code extension to change the color theme based on the current file language
Stars: ✭ 25 (-45.65%)
Mutual labels:  vscode-extension
vscode-wow-api
WoW extension for VSCode
Stars: ✭ 40 (-13.04%)
Mutual labels:  vscode-extension
clj-kondo.lsp
Clj-kondo language server and VSCode extension: https://marketplace.visualstudio.com/items?itemName=borkdude.clj-kondo
Stars: ✭ 17 (-63.04%)
Mutual labels:  vscode-extension
mirage
A Mirage blue theme with pastel tones for Visual Studio Code
Stars: ✭ 39 (-15.22%)
Mutual labels:  vscode-extension
Render-CRLF
This Visual Studio Code extension shows end-of-line character (CR, LF, or CRLF) when whitespace rendering is turned on.
Stars: ✭ 16 (-65.22%)
Mutual labels:  vscode-extension
vscode-checkpoints
Checkpoints for your code editing.
Stars: ✭ 27 (-41.3%)
Mutual labels:  vscode-extension
Bracketeer
VS Code extension for easy and quick manipulation with brackets and quotes.
Stars: ✭ 32 (-30.43%)
Mutual labels:  vscode-extension
vscode-gleam
📟 Gleam support for VS Code
Stars: ✭ 34 (-26.09%)
Mutual labels:  vscode-extension
vscode-create-file-folder
A small vscode extension that help you to create files & folder in Atom Style.
Stars: ✭ 27 (-41.3%)
Mutual labels:  vscode-extension
vscode-tlaplus
TLA+ language support for Visual Studio Code
Stars: ✭ 213 (+363.04%)
Mutual labels:  vscode-extension
vscode-sqflint
SQF Language server extension
Stars: ✭ 16 (-65.22%)
Mutual labels:  vscode-extension
vsc html5 boilerplate
This is a Visual Studio Code snippet extension for generating HTML 5 boilerplate code
Stars: ✭ 32 (-30.43%)
Mutual labels:  vscode-extension
vscode-interactive-graphviz
Interactive Graphviz Dot Preview for Visual Studio Code
Stars: ✭ 57 (+23.91%)
Mutual labels:  vscode-extension
vscode-servicebus-explorer
Service Bus Explorer Extension for Visual Studio Code
Stars: ✭ 17 (-63.04%)
Mutual labels:  vscode-extension
multicopy
VS Code extension to copy and paste multiple snippets of code in your workspace.
Stars: ✭ 29 (-36.96%)
Mutual labels:  vscode-extension
vim-eightheader
Vim plugin: Easily create custom headlines, foldtext, toc, etc
Stars: ✭ 17 (-63.04%)
Mutual labels:  folding
vscode-gitbook-kit
An Extension for VSCode to act as gitbook editor
Stars: ✭ 26 (-43.48%)
Mutual labels:  vscode-extension
Shortcut-Menu-Bar-VSCode-Extension
Add handy buttons like beautify, show opened files, save, toggle terminal, etc to the editor menu bar in VSCode. You can also create your own buttons with custom commands. VSCode Marketplace link: https://marketplace.visualstudio.com/items?itemName=jerrygoyal.shortcut-menu-bar
Stars: ✭ 126 (+173.91%)
Mutual labels:  vscode-extension
markdown-live
📝 Real-time Markdown Editor & Previewer for VS Code
Stars: ✭ 18 (-60.87%)
Mutual labels:  vscode-extension
vscode-javascript-booster
Sprinkle extra refactorings, code actions and commands over your JavaScript! 🍩 TypeScript and Flow are first class citizens as well!
Stars: ✭ 115 (+150%)
Mutual labels:  vscode-extension

Explicit Folding

License Visual Studio Marketplace Version Visual Studio Marketplace Installs License License License

This extension lets you manually control how and where to fold your code.

Configuration

In your settings:

"explicitFolding.rules": {
    "*": {
        "begin": "{{{",
        "end": "}}}"
    },
    "javascriptreact": [
        {
            "begin": "{/*",
            "end": "*/}"
        },
        {
            "begin": "<",
            "end": "/>"
        }
    ]
}

Rules

The property explicitFolding.rules defines how to fold the code.

Here the list of possible rules:

Global Scope

When used in the global scope, the rules must be grouped by language.

"explicitFolding.rules": {
    "cpp": [
        {
            "beginRegex": "#if(?:n?def)?",
            "middleRegex": "#el(?:se|if)",
            "endRegex": "#endif"
        }
    ]
}

Language Scope

"[cpp]": {
    "explicitFolding.rules": [
        {
            "beginRegex": "#if(?:n?def)?",
            "middleRegex": "#el(?:se|if)",
            "endRegex": "#endif"
        }
    ]
}

Regex Syntax

Via VSCode's editor, the extension supports ES2018 regexes (except \n).

The document parser is line-based. So \n and multi-lines regexes aren't supported.
The end of a line can be matched with $.

Additionally, the following aspects of PCRE2 syntax are supported:

  • (?i)x: x becomes case insensitive
  • (?i:x)y: only x is case insensitive

Wildcard Exclusions

By default, the wildcard rule, like the following, are applied to all languages.

"explicitFolding.rules": {
    "*": {
        "begin": "{{{",
        "end": "}}}"
    }
}

But, for languages which are using the indentation to define foldable blocks of code (such as in Python syntax), the wildcard rule will prevent the use of the indentation provider.
To avoid that, you need to add an exclusion:

"explicitFolding.wildcardExclusions": ["python"]

Auto Fold

You can define the automatic folding of the ranges with the property explicitFolding.autoFold (an enum, none by default).
Each rule can overwrite that property with its own property autoFold (a boolean, false by default).

So you can auto fold only the imports with:

"[javascript]": {
    "explicitFolding.rules": [
        {
            "beginRegex": "^import\\b",
            "whileRegex": "^(?:import\\b|\\/\\/)",
            "autoFold": true
        }
    ],
    "explicitFolding.autoFold": "none"
}

enum values

Debugging

If the property explicitFolding.debug (false by default) is true, the extension will print out debug information into the channel Folding of the panel Output (menu: View / Output).

Priority/Delay

VSCode is scoring each folding providers based on the scheme and language. When the scores are identical, the providers which have been registered the most recently, receive a higher priority.
When starting up, VSCode loads the installed extensions. When reading a file, VSCode will load the folding provider of the file's language (only once per language).

The property explicitFolding.delay (measured in milliseconds, and set to 1000 by default) is used so that this extension's folding provider has a higher priority than that of the language provider.

Notification

The property explicitFolding.notification (minor by default) indicates when to show the update notification.

Usages

Language Config
Emacs
"*": {
    "begin": "{{{",
    "end": "}}}"
}
C/C++
"cpp": [
    {
        "beginRegex": "#if(?:n?def)?",
        "middleRegex": "#el(?:se|if)",
        "endRegex": "#endif"
    },
    {
        "begin": "/*",
        "end": "*/",
        "nested": false
    },
    {
        "begin": "//",
        "continuation": "\\",
        "nested": false
    }
]
HTML
"html": {
    "beginRegex": "<(?!area|base|br|col|embed|hr|img|input|link|menuitem|meta|param|source|track|wbr)([a-zA-Z0-9]+)[^>\/]*>",
    "endRegex": "<\\/\\1>"
}
PHP
"php": [
    {
        "beginRegex": "(?:case|default)[^:]*:",
        "endRegex": "break;|(.)(?=case|default|\\})",
        "foldLastLine": [true, false]
    },
    {
        "beginRegex": "\\{",
        "middleRegex": "\\}[^}]+\\{",
        "endRegex": "\\}"
    }
]
Python
"python": {
    "beginRegex": "\"\"\"",
    "endRegex": "\"\"\""
}
SASS
"scss": {
    "beginRegex": " \\{\\s*$",
    "endRegex": "^\\s*\\}"
}

FAQ

Q: Why don't I see the foldings?

A: Firstly, make sure you have the setting "editor.showFoldingControls": "always" defined, and that you don't have "editor.foldingStrategy": "indentation" defined. Then, verify your configuration. 😉

Q: Why doesn't \n work?

A: The document parser is line-based. So in order to match the end of a line, you need to use $.

Donations

Support this project by becoming a financial contributor, using any of the following methods:

Ko-fi ko-fi.com/daiyam
Liberapay liberapay.com/daiyam/donate
PayPal paypal.me/daiyam99

Supported Editors

VSCode/VSCodium

VSCode uses the folding ranges provided:

  • by the folding range provider defined by the setting editor.foldingStrategy (auto or indentation)
  • and, by the folding range provider defined by this extension if editor.foldingStrategy is set to auto

MrCode

MrCode is using the folding ranges provided:

  • by the folding range provider defined by the setting editor.foldingStrategy (auto or indentation)
  • or by the folding range provider defined by this extension if editor.foldingStrategy is set to explicit

The long-standing PR tries to bring this new behaviour to VSCode.

Enjoy!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].