18

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

2
  • 1
    Thanks for the awesome replies all. Shame I can't mark all your comments as the answer. Commented Nov 25, 2011 at 10:54
  • It may be helpful for you i guess. Coffee-Bytes for Eclipse 3.6 & higher: stackoverflow.com/questions/8534542/… Commented Jan 3, 2012 at 7:56

4 Answers 4

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

Sign up to request clarification or add additional context in comments.

Comments

13

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.

Comments

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

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.