Is there a way to collapse only methods and doc blocks on demand in PhpStorm?
Asked Answered
E

3

6

I have seen this question but if I apply the Ctrl+Shift+- shortcut it collapses everything including class, method, doc, if/try-catch/foreach etc. Basically every block within curly braces are folded which makes it a p.i.t.a to view code. I want to reduce the visual clutter, so what I would like to see is only the method and doc blocks collapsed, so that I can quickly navigate to method and inspect code from thereon.

Embolectomy answered 11/11, 2015 at 12:19 Comment(0)
E
14

After spending some time with the IDE I figured it out for myself. One can do Ctrl+Shift+- and then Ctrl+Shift++. Basically the first shortcut action collapses everything and the second action expands everything but method definitions and doc blocks. If you apply Ctrl+Shift++ a second time then PhpStorm expands everything including methods and docs.

This can be effected from the menu (without shortcuts) using mouse with the following steps:

1. Menu -> Code -> Folding -> Expand all to level -> 5
2. Menu -> Code -> Folding -> Expand all to level -> 1

This does the reverse operation of the first method, i.e. first expands everything and then collapses just methods and docs, but the effect is the same.

I use NetBeans keymap scheme, so things might be slightly different at your side, but the idea is the same.

Embolectomy answered 11/11, 2015 at 13:26 Comment(1)
This does not work for me on 2020.3.2, sadly. The crtr/shift/plus just opens up bloody everything. A ctrl/plus opens the class only, however if I open a further block - eg going there by a bookmark - all the bloody code folds remain. This code folding is a major problem with phpstorm, it's not very useful as it is.Sciomachy
R
3

You can try the below method from Jetbrains website

enter image description here

Renell answered 27/3, 2017 at 10:41 Comment(0)
P
1

The accepted answer does not seem to work any more.

Instead, after you have collapsed all (Shift+Command (⌘)+-), you can then hold Command (⌘) and click on the '+' code folding toggle to the left of the editor to recursively expand the whole folded region.

P.S. Sorry the shortcut keys are for mac, not sure what the windows shortcuts are.

Phylloxera answered 28/10, 2022 at 9:57 Comment(1)
Confirmed on windows with ctrl-shift-"-" and ctrl with click on "+".Gaelic

© 2022 - 2024 — McMap. All rights reserved.