Sublime Forum

Code Folding syntax definition

#1

Hi guys, I haven’t posted in a little while (work got SUPER busy) but I wonder if someone could give me a quick bit of help understanding how you define in a Syntax file how code should be folded.

If I understand correctly, anything between what the foldingStartMarker matches and what the foldingStopmarker matches will be folded (or to put it another way, fold arrows will appear at matches for the foldingStartMarker and collapse the code until the foldingStopMarker match). However, I’ve noticed that there seem to be hierarchies of code folding (Fold Level in the Edit -> Code Folding sub-menu). This would be really useful in the language I’m writing for and if it’s possible I’d love to make use of it. Can anybody explain (or point me to a doc or something) how you define the level of folding? And just to be clear, this would allow you to do nested folding correct?

Thanks in advance guys!

0 Likes

#2

I don’t think Sublime Text looks at the tmlanguage start and end fold markers… I think it does its own folding based on indentation?

0 Likes

#3

Oh man I’d msiread the docs. So there’s no way to define custom folding points?

0 Likes

#4

I don’t think so… :frowning:

0 Likes

#5

Does anybody else have any idea? This would be a reeeeally useful feature. My company’s proprietary language is pretty crazy to use, so I rely on ST2 to make my job bearable.

0 Likes

#6

I’d really like syntax-enabled folding as well.
There’s a lot of code I don’t want to see, mainly in-line documentation.
It’d be great if I could creating syntax folders to hide it with something like #region and #endregion.

0 Likes

#7

I literally just finished reading this article: codinghorror.com/blog/2008/0 … lding.html :smile:

0 Likes

#8

Well, he has a fair point there. But I accept one use for ‘code’ folding and that’s for my in-line documentation. When all of my methods, classes etc have more XML documentation than code and the documentation is very lengthy, I’d like to collapse these when working on the code in order to prevent my scroll wheel from dying and myself being able to comprehend the code. If I need to look up the documentation anyway, I can always expand or look up the extracted documentation files. I want to use the folding for the exact reason Jeff stated: I want to see my code!

0 Likes

#9

Could be nice to have the same code folding MSVC has (see attachment).

0 Likes