79

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?

Manuel Jordan
  • 15,253
  • 21
  • 95
  • 158
dw.mackie
  • 2,025
  • 1
  • 17
  • 18

3 Answers3

129

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.

Jasper
  • 2,166
  • 4
  • 30
  • 50
JMD
  • 7,331
  • 3
  • 29
  • 39
  • 1
    NOTE: If you don't see the "-"s/"+"s on blocks, then "folding" is disabled. Rt-Click on the gutter (where you would normally see those "+"s), select "Folding > Enable Folding". (Here you will also see the keyboard shortcuts for the various folding actions.) `Ctrl`+`Numpad_Divide` is the shortcut to toggle enable folding on/off. This is annoying, because that is easy to do by accident instead of `Ctrl`+`Shift`+`Numpad_Divide`, which is what you often want to do when you open a file, to collapse everything, to see the overall structure. – ToolmakerSteve Sep 11 '14 at 17:07
  • So it appears that I had folding disabled. If anyone needs to enable folding under the version of Eclipse I was using it could be found under Window -> Preferences -> Java -> Editor -> Folding. – StuckOnSimpleThings Jun 09 '15 at 16:55
92

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

Jasper
  • 2,166
  • 4
  • 30
  • 50
  • 4
    @petrilli What is Numpad_plus on macbook pro? I don't have a number keypad. – Roy Hinkley May 29 '14 at 15:42
  • Some laptops have a virtual numpad if you use the FN or NumLock key. I don't think macs have that, so you're better off just rebinding the keys to something else. – wisbucky Apr 19 '18 at 23:15
8

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

Mohammad Alhashash
  • 1,543
  • 1
  • 14
  • 30
Crazyshezy
  • 1,530
  • 6
  • 27
  • 45