[eclipse] Is there a way to collapse all code blocks in Eclipse?

Eclipse has that "+/-" on the left to expand and collapse blocks of code.

I've got tens of thousands of lines to go through and would really like to just collapse everything, and selectively expand blocks to look at them.

This question is related to eclipse ide

The answer is


If you always want the code collapsed by default, go to Windows > Preferences. Search for "folding". Then check all the items under "Initially fold these elements".

enter image description here


Right click on the circles +/- sign and under Foldings select Collapse All


Shortcuts that worked for me in Versions Oxygen.2 Release (PHP/WINDOWS 7) were

  1. Collapse all code blocks: CTRL + SHIFT + NUMPAD_DIVIDE
  2. Expand all code blocks : CTRL + NUMPAD_MULTIPLY

I noticed few things:

Ctrl+/ toggles Folding-enabled or -disabled.

It is Ctrl+* that expands. Ctrl+Shift+* collapses just like Ctrl+Shift+/


Ctrl+Shift+/ and Ctrl+Shift+* works great for Aptana Studio 3.

Apart from that you can always use Window > Preferences > Editors > Foldings to enable it


If you are using PyDev in Eclipse, its Ctrl0 and Ctrl9 for collapse all and uncollapse all respectively. Ctrl- and Ctrl= to collapse individual methods when your cursor is on the line of the method declaration.


In addition to the hotkey, if you right click in the gutter where you see the +/-, there is a context menu item 'Folding.' Opening the submenu associated with this, you can see a 'Collapse All' item. this will also do what you wish.


Collapse all : CTRL + SHIFT + /

Expand all code blocks : CTRL + *


In case you don't have a separate numpad, you can activate the overlapping numpad using the number lock- this varies with the type of keypad-> fn + numlk for hp

then try ctrl + shift + numpad_Divide

should work fine


Just to sum up:

  1. anycode:
    • ctrl + shift + NUMPAD_divide = collapse all
    • NUMPAD_multiply = exand all
  2. pydev:
    • -ctrl + 0 = collapse all
    • -ctrl + 9 = exand all

A "Collapse All" command exists in recent builds (e.g. 3.2 M6) and is bound to Ctrl+Shift+NUM_KEYPAD_DIVIDE by default.

You can also configure it in Preferences->Editor->Keys.


I had the same problem and found out Folding can be enabled or disabled, and in my case got disabled somehow.

To solve it, simply right click on the line numbers/breakpoint section (vertical bar in the left of the editor), then under the 'Folding' section chose 'Enable folding'.

ctrlshift/ should be working fine after.


The question is a bit old, but let me add a different approach. In addition to the above hot-key approaches, there are default preference settings that can be toggled.

As of Eclipse Galileo (and definitely in my Eclipse Version: Indigo Service Release 2 Build id: 20120216-1857) language specific preferences can open up new files to edit which are already collapsed or expanded.

Here is a link to Eclipse Galileo online docs showing the feature for C/C++: http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.cdt.doc.user/reference/cdt_u_c_editor_folding.htm .

In my Eclipse Indigo I can open the Folding Preferences window via : menu/ Window/ Preferences/ Java/ Editor/ Folding and set all options on so I can open files by default that are completely collapsed.


Right click on the +/- sign and click collapse all or expand all.


Examples related to eclipse

How do I get the command-line for an Eclipse run configuration? My eclipse won't open, i download the bundle pack it keeps saying error log strange error in my Animation Drawable How to uninstall Eclipse? How to resolve Unable to load authentication plugin 'caching_sha2_password' issue Class has been compiled by a more recent version of the Java Environment Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory How to downgrade Java from 9 to 8 on a MACOS. Eclipse is not running with Java 9 "The POM for ... is missing, no dependency information available" even though it exists in Maven Repository The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. on deploying to tomcat

Examples related to ide

How can I view the Git history in Visual Studio Code? How to ignore a particular directory or file for tslint? How do I completely rename an Xcode project (i.e. inclusive of folders)? Where is the visual studio HTML Designer? How to disable gradle 'offline mode' in android studio? Android studio Error "Unsupported Modules Detected: Compilation is not supported for following modules" Android Studio was unable to find a valid Jvm (Related to MAC OS) QtCreator: No valid kits found Difference between WebStorm and PHPStorm package android.support.v4.app does not exist ; in Android studio 0.8