+11

Recursive code folding

Norris Wyvern 8 years ago • updated by Peter Epp 7 years ago 3
Currently CMD+K1 Folds all 1st level code. I'd very much like to see a code fold that does recursive fold. Meaning, that after I fold, I have to unfold one by one to get where I want to.
I mean: CMD+k1 would produce CMD + k9, CMD + k8, ....CMD + k2, CMD + k1.
I think I understand what you mean. Currently folding at level one will fold everything up. But what you want is for everything to be folded at the appropriate level? That is, fold every level while having every level still visible? I'd like that as well.

Sort of like a tree outline in a file browser... you want to see every level, but not stuff below folders, until you click on the triangle or plus icon to the left to unfold that node.
The best way is to look at how Cloud9ide has done it. It's brilliant! I would love to see that in Sublime as well.

Basically when you hit CMD+K2 then it will be at 2nd level. When you hit CMD+K4 then it will be the 4th level. You don't have to hit CMD+KJ before you show the 4th level.

I like the way TextMate did code folding - if you held down the option key (Mac) and click the triangle, it would fold that block recursively - the block and all it's child blocks got folded. If you then clicked again to open it but without holding the option key, it would only unfold that block, leaving all child blocks still folded. I find this super useful when I have a really large PHP or JS object, as I can fold the entire thing, scan through it to find the code I want and then just unfold that bit to work on it.


This functionality also worked in TextMate's folder list, which is consistent with how folding works in the Mac OS Finder's list views.