ambertch
ambertch

Reputation: 7649

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.

Upvotes: 572

Views: 266719

Answers (17)

Pooja Pilankar
Pooja Pilankar

Reputation: 1

Keys are not working for me but there is pane where row nos are written, RC -> Folding-> Collapse and Expand option is present you can use them.

let me know if you find this answer interesting :-) Happy learning.

Upvotes: 0

Manshu Shivam
Manshu Shivam

Reputation: 1

i was using lapop numpad was orange color which will get enable using function (Fn) button ...so try

shift + crtl + fn + (see where is divide) in my case its on 0

Upvotes: 0

Alwaysa Learner
Alwaysa Learner

Reputation: 496

I noticed few things:

Ctrl+/ toggles Folding-enabled or -disabled.

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

Upvotes: 1

Abd Abughazaleh
Abd Abughazaleh

Reputation: 5495

Collapse all : CTRL + SHIFT + /

Expand all code blocks : CTRL + *

Upvotes: 0

av003
av003

Reputation: 1

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

Upvotes: 0

Abhishek kandari
Abhishek kandari

Reputation: 196

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

Upvotes: 1

David Neto
David Neto

Reputation: 808

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.

Upvotes: 3

lightalchemist
lightalchemist

Reputation: 10211

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.

Upvotes: 4

Hittz
Hittz

Reputation: 687

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

Upvotes: 8

wisbucky
wisbucky

Reputation: 37797

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

Upvotes: 12

NightSkyCode
NightSkyCode

Reputation: 1141

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

Upvotes: 9

Monica Arsela
Monica Arsela

Reputation: 41

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

Upvotes: 4

ChssPly76
ChssPly76

Reputation: 100686

There is a hotkey, mapped by default to Ctrl+Shift+NUM_KEYPAD_DIVIDE.

You can change it to something else via Window -> Preferences, search for "Keys", then for "Collapse All".

To open all code blocks the shortcut is Ctrl+Shift+NUM_KEYPAD_MULTIPLY.

In the Eclipse extension PyDev, close all code blocks is Ctrl + 9

To open all blocks, is Ctrl + 0

Upvotes: 893

Mark Mayo
Mark Mayo

Reputation: 12585

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.

Upvotes: 29

partizanos
partizanos

Reputation: 1126

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

Upvotes: 6

donfede
donfede

Reputation: 734

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.

Upvotes: 11

akf
akf

Reputation: 39475

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.

Upvotes: 151

Related Questions