Closed edgimar closed 11 months ago
Maybe with a config like:
"explicitFolding.rules": [
{
"separatorRegex": "\\/\\/\\/ \\*(?=\s|$)",
"strict": "never",
"nested": [
{
"separatorRegex": "\\/\\/\\/ \\*\\*",
}
]
}
],
autoFold
is only there to fold the folding ranges when a file is opened.
Will those rules handle more than one nested level? My example above only shows two levels, but the idea is to have an arbitrary nesting depth (or, at least up to 5 or 6).
I guess something like the following should work:
"explicitFolding.rules": {
"": {
"separatorRegex": "\\/\\/\\/ \\*(?=\\s|$)",
"strict": "never",
"nested": [
{
"separatorRegex": "\\/\\/\\/ \\*\\*(?=\\s|$)",
"nested": [
{
"separatorRegex": "\\/\\/\\/ \\*\\*\\*(?=\\s|$)",
"nested": [
{
"separatorRegex": "\\/\\/\\/ \\*\\*\\*\\*(?=\\s|$)",
"nested": [
{
"separatorRegex": "\\/\\/\\/ \\*\\*\\*\\*\\*(?=\\s|$)",
}
]
}
]
}
]
}
]
}
},
Emacs has a nice package called
outline-minor-mode
which allows one to create explicit folds by simply adding special comment lines that mark only the beginning of a folding region (and indicate the folding level). For example:When fully folded, this would appear as:
and if we unfold '1' and '(b)' (which is a fold nested within fold '1'), we will see:
It isn't clear to me if there's a way to do this using the "Auto Fold" functionality. If not, it would be nice if one could simply specify a regular expression that includes a capture group, and when the expression matches, the length of the captured text indicates the depth of the fold -- in the example above, the regex would attempt to capture the series of asterisks on lines like
/// ** foo
.