Is there a keyboard shortcut in Eclipse to fold the current method/block?

EclipseIdeKeyboard Shortcuts

Eclipse Problem Overview


Hey, question says it all. I have folding turned on in Eclipse (v3.4), and rather than having to click the little +/- in the page gutter, I'm wondering if there's a keyboard shortcut to just "fold the current method". A quick look at the menus and what-not in eclipse doesn't show a menu item for it, so maybe you just can't do it.

Anyone?

Eclipse Solutions


Solution 1 - Eclipse

To expand on petrilli's answer:

  • Ctrl + Numpad_Multiply can also be used to expand all
  • Ctrl + Shift + Numpad_Divide is bound to collapse all
  • Ctrl + Numpad_Divide toggles folding on and off

And yes, they can all be rebound, if you know what text to filter on in Windows | Preferences | General | Keys.

"Folding", "Expand", "Collapse" are keywords that should get you all of the relevant commands.

Solution 2 - Eclipse

By default they're bound to Ctrl + Numpad_Minus and Ctrl + Numpad_Plus, but you can rebind them.

Solution 3 - Eclipse

If you are using eclipse-pydev then the default keybinds are

ctrl + 9 : collapse all one level

ctrl + 0 : expand all one level

ctrl + -_ : collapse current location

ctrl + =+ : expand current

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questiondw.mackieView Question on Stackoverflow
Solution 1 - EclipseJMDView Answer on Stackoverflow
Solution 2 - EclipsepetrilliView Answer on Stackoverflow
Solution 3 - EclipseCrazyshezyView Answer on Stackoverflow