Maybe I missed something ... I recently migrated my javascript project from netbeans to visual studio code ... in netbeans we use
//<editor-fold defaultstate="collapsed" desc="MySection">
...
//</editor-fold>
for defining regions ... I saw I could modify javascript-language-configuration.json to
"folding": {
"markers": {
"start": "^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))",
"end": "^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))"
}
}
SO my request includes 2 questions :
Configuring additional folding markers in the settings is #36002.
Sorry, but comment-folding wont help me - mostly all docs will be generated from source, more and more; why not completely hide them? I do not want to see any comment in my code when coding. It is never needed! It's only needed after a long break or mostly for others. So, why should we look every day, hour and minute on them? It cannot be a problem to hide them, if folding is already available in an IDE/Editor :|
But - can i actually fold them to only a single char, like 禄
?
And whats about
// line
// line
// line
...
# line
# line
...
/*
...
...
*/
as they are in several documents? Copy & Paste would might break all rules every time i do that (without saying Copy & Paste is accurate - but have a look at all ressources for coders). Nobody would write this by self every day when learning a new framework or software.
Yes! Regions should be folded by default when you open the editor (assuming that it's impossible to remember the last state of that region between session). They are kind of useless right now to me because I use regions to hide complexity but every time I open a file in c# the regions are all unfolded so it's actually a pointless feature for what I think it was intended to be.
Would love to have import blocks automatically folded in files with a simple user setting.
Would love to have import blocks automatically folded in files with a simple user setting.
Like in WebStorm.
Is there anything we can do to help get this out?
just add the attribute to "#region"
e.g. #region collapsed
just add the attribute to "#region"
e.g.
#region collapsed
So all your regions will be named collapsed
? 馃
Normally, we put a name after #region
I mean, the #region
tool is already built-in, we just need to extend it.
This technology is already built into "VSCode".
Syntax in this case is secondary, for example, camelCase can be used.
//#region Some name or description
// - ,-
//#regionEnd
//#regionCollapsed Some name or description
// - ,-
//#regionEnd
The current syntax #endregion
is a weirder than the one I suggest ...
I mean, the
#region
tool is already built-in, we just need to extend it.
I don't agree. It makes sense only for very custom regions.
As I mentioned in #84844 I would like to default collapse all inline SVGs. And it's crazy to refactor whole project to add such #region
to every SVG in project. If I can fold regions basing on custom regex, then I can fold SVGs without any change in code, as SVG is pretty easy to spot using regex. Using region can be considered only as temporary substitution.
I also do not agree; the use case for auto-collapsed imports is pretty important to many, and wrapping them in an explicit #region
would be silly since they are already an implicit foldable region.
Initially, I came here in the search for settings as
ctrl + K ctrl + J
- editor.unfoldAllctrl + K ctrl + 2
- editor.foldLevel2by default.
All I could find was "felicio.vscode-fold" from the marketplace.
In a previous post, I want to say that instead of inventing a new tool and new XML like syntax, it is possible to use the existing "#region" functionality. This applies to the original "issue".
Here's an example of the payload returned by the Java language server:
[Trace - 9:52:58 AM] Received response 'textDocument/foldingRange - (822)' in 318ms.
Result: [
{
"startLine": 2,
"endLine": 16,
"kind": "imports"
},
{
"startLine": 18,
"endLine": 27
},
{
"startLine": 21,
"endLine": 23
},
{
"startLine": 25,
"endLine": 26
}
]
Everything's already in place in folding.ts to fold blocks based on kind: https://github.com/microsoft/vscode/blob/9b18eade1b1f0c12b179a7be7e03a85c6513d60d/src/vs/editor/contrib/folding/folding.ts#L736
Then you could expose new settings, so that we could set something like:
editor.folding.initialState: [
{"imports":true},
{"comment":true},
{"region":false},
]
@fbricon Really awesome! Wish I had time to contribute such a setting. Thanks for digging. Hopefully some kind person implements it for TS eventually =)
This could only work based on kind
through ..
So if you want to collapsed some long functions in the long run or private functions by default, you wouldn't be able to.
Would love this! 馃殌
Most helpful comment
Would love to have import blocks automatically folded in files with a simple user setting.