Search code examples
phpstormfolding

PhpStorm - can you "collapse to level" without recursion?


One feature that I miss from Visual Studio (and which I've never seen anywhere else) is "collapse methods" or something like that. In essence, you collapse method (function) bodies and ONLY function bodies. That is, if there is an if statement inside that function, it DOESN'T get collapsed. So that when you expand the function body, it ALL gets expanded.

In PhpStorm you can collapse starting at level X (which would work), but it then also recursively collapses everything below that level, which isn't what I want at all. I just want to collapse all methods at their top level so that I can see a class with its method names, and then when I click a particular method to expand, I want it all to get expanded and see the full source.

Is this possible somehow?


Solution

  • Not currently possible 😒 . Maybe some custom plugin... but I'm not aware of such.

    Watch these and related tickets (star/vote/comment) to get notified on any progress:

    P.S. IDE has Settings/Preferences | Editor | General | Code Folding --> Fold by default but at the same time it does not provide an action to re-apply that folding on request (separate action that can be invoked at any time). It's https://youtrack.jetbrains.com/issue/IDEA-80100


    The best you can do here is:

    1. Use "Collapse All"
    2. Click on [+] for each method when needed with Alt key pressed (this will recursively expand/collapse all sub levels). Or use a keyboard shortcut (Code | Folding | Expand Recursively).