Is it possible to customize the way code folding works in Visual Studio Code?
I use a common pattern of defining regions of code across a variety of different document
Now, there are three ways to achieve customized folding in a VSCode extension.
{
"folding": {
"markers": {
"start": "starting regex",
"end": "ending regex"
}
}
}
Can define a FoldingRangeProvider from the extension side as described in this answer. FoldingRange in vscode package supports folding customization with startLine, endLine, and foldingKind.
Can use Language Server support with textDocument/foldingRange. FoldingRange in vscode-languageserver-protocol supports folding customization with startLine, endLine, startCharacter, endCharacter, and foldingKind.
Check this for more details.