Code Folding (recursive)


When option-clicking on a code fold, I prefer the tool to recursively fold at all points contained in that tree. This allows you to quickly and easily see a map of say an object if you option-click the top element to fold it and then normal click to unfold at that top level without having the child folds expand.


Related, the same thing in the file tree:


+1 for this feature. overviewing objects, classes, etc… is much simpler with recursive code folding… pls add this feature


I’m really looking for something like this. In PyCharm I got used to folding all my code with a shortcut (so that I have a nice overview of the code), and then fully unfold the class/function I want to work on.

With Atom half of this works (Ctrl+Alt+Shift+[ to fold everything), but unfolding is either only one level or everything in the entire file. I’m looking for a way to recursively unfold only the fold my cursor is in.


Something similar came up in a different thread about a year ago and I came up with a solution that I think will work for you. Put the following code in your It will fold your entire editor and then recursively unfold levels until the row your cursor is on has been unfolded.

atom.commands.add 'atom-text-editor', 'custom:fold-all-except-current-row', (evt) ->
  atom.commands.dispatch, 'editor:fold-all'
  while atom.workspace.getActiveTextEditor().isFoldedAtCursorRow() == true
    atom.commands.dispatch, 'editor:unfold-current-row'

Filter lines containing string and be able to edit

Thanks! It won’t work for me as-is, since it folds everything except what I want to unfold and that’s not what I want (it shouldn’t touch anything except the thing I want to unfold). However, it does give me a good start to script something myself.