17

Just curious if there's a setting somewhere in Eclipse to keep blocks of code collapsed when the class is opened? It's just I'll collapse methods then when the class is re-opened, everything is expanded.

Thanks

Ash
  • 3,494
  • 12
  • 35
  • 42
  • 1
    Thanks for the awesome replies all. Shame I can't mark all your comments as the answer. – Ash Nov 25 '11 at 10:54
  • It may be helpful for you i guess. Coffee-Bytes for Eclipse 3.6 & higher: http://stackoverflow.com/questions/8534542/what-code-folding-plugins-work-on-eclipse-3-6 – Yaqub Ahmad Jan 03 '12 at 07:56

4 Answers4

26

In Windows > preferences:

Java > editor > folding: check all, click apply & then OK.

Maybe this helps: Ctrl + Shift+ NUM_KEYPAD_DIVIDE collapse all methods in a java class.

Eclipse Source Code Folding

Source

Community
  • 1
  • 1
Yusuf K.
  • 4,195
  • 1
  • 33
  • 69
12

Yes . From the eclipse official documentation :

You can specify which regions are folded by default when an editor is opened. Have a look at the Opens the folding preference page Java >Editor > Folding preference page to customize this.

enter image description here

Just click all the checkboxs .Then whenever a .java file is open in the java editor , everything will be collapsed.

Not sure if this options is the new feature for eclipse indigo version (3.7) , so you may have to update your eclipse to indigo if you use older version but cannot find this option.

Ken Chan
  • 84,777
  • 26
  • 143
  • 172
2

I'm not aware of a solution, but let me tell you how I work - maybe this is a solution for you as well:

  1. Enable "Only show the selected Java element". The editor will only show the element (method) you selected (see screenshot).

  2. While editing a file use either the Outline view or CTRL + O to navigate through the class file.

Btw: I disabled all folding options as the above approach just works best for me. Sadly, I'm not aware of a shortcut to enable/disable the "Only show the selected Java element".

enter image description here

home
  • 12,468
  • 5
  • 46
  • 54
1

Yes, you can set the options what to fold on file open.

You can find it at Settings->Editor->Folding

It features a resonable selection of folding options.

kostja
  • 60,521
  • 48
  • 179
  • 224