How to collapse blocks of code in Eclipse?

EclipseCode Editor

Eclipse Problem Overview


Some days ago my Eclipse was working fine and a +/- appeared in every block that could be collapsed (functions, classes, etc.)... but now it does appear, and I don't know how to activate that feature again.

It's Eclipse Helios, running on a Gentoo Linux box.

Eclipse Solutions


Solution 1 - Eclipse

Preferences -> C++ -> Editor -> Folding ?

Make a right click in the editor window and go to preferences there, then only the editor-relevant section of the preferences dialog will appear. This works for JDT, CDT etc...

Solution 2 - Eclipse

You can do ( Ctrl + Numpad_Divide ) to enable folding.
Also if you Right Click on the area where the + or - was supposed to be, you can see there is a folding option.

Solution 3 - Eclipse

Try this option: Preferences > Java > Editor > Folding > Enable folding

Solution 4 - Eclipse

To collapse all code blocks Ctrl + Shift+ /

To expand all code blocks Ctrl + Shift+ *

pydev:

To collapse all code blocks : Ctrl + 0

To collapse all code blocks : Ctrl + 9

https://stackoverflow.com/questions/1726525/is-there-a-way-to-collapse-all-code-blocks-in-eclipse

by @partizanos and @bummi

Solution 5 - Eclipse

For Python it is as follows:

  • collapse all 1 level: Ctrl+9
  • expand all 1 level: Ctrl+0
  • collapse current: Ctrl+-
  • expand current: Ctrl++

Hope that helps.

Solution 6 - Eclipse

In Preferences, you'll find General > Keys. It's for setting your keyboard shortcuts.

What I use it for more often, though, is to find stuff in Eclipse. You should see an input box labelled "type filter text." It's as close as Eclipse comes to a search feature for every Eclipse command.

Solution 7 - Eclipse

I assume you are using Java, but look under the settings for your particular language.

Under the Window menu, select Preferences.

Under Java->Editor->Folding. Select "Enable Folding".

Solution 8 - Eclipse

If you want folding an all your editors, I found you can enable Folding in

Preferences > Editors > Structured Text Editors

Enable Folding

Solution 9 - Eclipse

For windows eclipse using java: Windows -> Preferences -> Java -> Editor -> Folding

Unfortunately this will not allow for collapsing code, however if it turns off you can re-enable it to get rid of long comments and imports.

Solution 10 - Eclipse

Here you go!

  1. Right Click on + button appeared on numbering strip on left most side --> Folding --> Expand All
  2. Right Click on + button appeared on numbering strip on left most side --> Folding --> Collapse All

This way you can expand and collapse all the methods on the file.

Plus Buttons on numbering strip

Context Menu:

Context Menu

Solution 11 - Eclipse

In CFEclipse: Preferences > CFEclipse > Editor > Code Folding > Initially Collapse column, you can uncheck to see all expanded when opening, or check all boxes to close all when opening a file.

Solution 12 - Eclipse

I was using salesforce apex classes with Eclipse Neon 3.3 for Java.
I found an option "define folding region" on right click in the editor, I selected the block of code i wanted to collapse and selected this property for that code. Now I am seeing + and - symbol to expand and collapse that block of code

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
QuestionCristianView Question on Stackoverflow
Solution 1 - EclipseIanHView Answer on Stackoverflow
Solution 2 - EclipseKenny PengView Answer on Stackoverflow
Solution 3 - EclipseChris LercherView Answer on Stackoverflow
Solution 4 - EclipseThiagoView Answer on Stackoverflow
Solution 5 - Eclipsemmrs151View Answer on Stackoverflow
Solution 6 - EclipseJames MooreView Answer on Stackoverflow
Solution 7 - EclipseStarkeyView Answer on Stackoverflow
Solution 8 - EclipseBrigView Answer on Stackoverflow
Solution 9 - EclipseElijahView Answer on Stackoverflow
Solution 10 - EclipseHamid Raza AbdulView Answer on Stackoverflow
Solution 11 - EclipseKim WilsonView Answer on Stackoverflow
Solution 12 - EclipseAkshay Vijay JainView Answer on Stackoverflow