Manually controls how and where to fold your code
In your settings:
"explicitFolding.rules": {
"*": {
"begin": "{{{",
"end": "}}}"
},
"javascriptreact": [
{
"begin": "{/*",
"end": "*/}"
},
{
"begin": "<",
"end": "/>"
}
]
}
The property explicitFolding.rules is defining how to fold the code.
Here the list of possible rules:
When used in the global scope, the rules must be regrouped by language.
"explicitFolding.rules": {
"cpp": [
{
"beginRegex": "#if(?:n?def)?",
"middleRegex": "#el(?:se|if)",
"endRegex": "#endif"
}
]
}
"[cpp]": {
"explicitFolding.rules": [
{
"beginRegex": "#if(?:n?def)?",
"middleRegex": "#el(?:se|if)",
"endRegex": "#endif"
}
]
}
Via VSCode's editor, the extension supports ES2018 regexes.
In addition, the following PCRE2 syntaxes are supported:
(?i)x:xbecomes case insensitive(?i:x)y: onlyxis case insensitive
If the property explicitFolding.debug (false by default) is true, the extension will print out debug informations into the channel Folding of the panel Output (menu: View / Output).
VSCode is scoring each folding providers based on the scheme and language. When the scores are identicals, the providers which have been registered the latest have an higher priority. When starting up, VSCode loads the extensions. When reading a file, VSCode will load the folding provider of the file's language (only once per language).
The property explicitFolding.delay (in ms, 1000 by default) is used so that this extension's folding provider has a higher priority than the one of the language provider.
The property explicitFolding.notification (minor by default) indicates when to show the update notification.
| Language | Config |
|---|---|
| Emacs |
|
| C/C++ |
|
| HTML |
|
| PHP |
|
| Python |
|
| SASS |
|
Q: Why don't I see the foldings ?
A: Firstly, make sure you have the setting "editor.showFoldingControls": "always" and that you don't have "editor.foldingStrategy": "indentation". Then, verify your config 😉
Support this project by becoming a financial contributor.
| ko-fi.com/daiyam | |
| liberapay.com/daiyam/donate | |
| paypal.me/daiyam99 |
VSCode is using the folding ranges provided:
- by the folding range provider defined by the setting
editor.foldingStrategy(autoorindentation) - and, by the folding range provider defined by this extension if
editor.foldingStrategyis set toauto
MrCode is using the folding ranges provided:
- by the folding range provider defined by the setting
editor.foldingStrategy(autoorindentation) - or by the folding range provider defined by this extension if
editor.foldingStrategyis set toexplicit
The long-standing PR tries to bring this new behaviour to VSCode.
Enjoy!