Ash
Ash

Reputation: 3532

Keeping Code Collapsed - Eclipse IDE

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

Upvotes: 18

Views: 8739

Answers (4)

Yusuf K.
Yusuf K.

Reputation: 4250

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

Upvotes: 26

Ken Chan
Ken Chan

Reputation: 90417

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.

Upvotes: 13

home
home

Reputation: 12538

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

Upvotes: 2

kostja
kostja

Reputation: 61538

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.

Upvotes: 1

Related Questions