Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 972
nawfal Avatar asked Nov 11 '15 12:11

nawfal


People also ask

How do I minimize all methods in PyCharm?

To collapse or expand all code fragments, press Ctrl+Shift+NumPad - / Ctrl+Shift+NumPad + . PyCharm collapses or expands all fragments within the selection, or, if nothing is selected, all fragments in the current file, for example, all methods in a file.

How do I minimize all functions in Webstorm?

Key board short cut : Hold down ctrl shift - to collapse them all.


1 Answers

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.

like image 102
nawfal Avatar answered Oct 30 '22 16:10

nawfal