pythonpycharmkeyboard-shortcutsfolding

Shortcut to colllaspe/fold all methods in PyCharm


I'm mainly working on PyCharm, and lot of times, I come into a situation where it would be much better if I can collapse/fold all method bodies, and leave their names only.

The picture below is the the result I want, but I can't find the shortcut to do this thing. If you know any, let me know.

c


Solution

  • You can collapse the code as shown in the screenshot going to Code > Folding > Expand All to Level > 1 or using the keyboard shortcut Ctrl + Shift + NumPad *, 1.

    The level is absolute relative to the module level. If you have nested methods or classes you can select them individually an use the equivalent Expand to Level instead of Expand All to Level.

    enter image description here