94

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.

Guy Avraham
  • 3,482
  • 3
  • 38
  • 50
Cristian
  • 198,401
  • 62
  • 356
  • 264
  • 4
    In Preferences -> C++ -> Editor -> Folding there is a checkbox: "Enable folding of control flow statements". You may not see anything immediately because computing the fold points may happen slowly in the background, or it may be necessary to invoke the "Reset Structure" command shift+ctrl+numpad_multiply, to get eclipse to show all the fold points. – Phill Apley May 14 '14 at 15:39

12 Answers12

98

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...

IanH
  • 3,968
  • 2
  • 23
  • 26
  • 10
    Another way is to right-click the narrow vertical bar has has all of the (+)/(-) little pluses and minuses. The option to fold the code will be there. – Anonsage Mar 19 '13 at 16:19
  • 1
    In current Eclipse, I do not see any "Folding" option under editor for each language. Instead, @KennyPeng's answer is what works for me. – ToolmakerSteve Jun 24 '15 at 16:26
60

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.

Ahmed Nabil
  • 17,392
  • 11
  • 61
  • 88
Kenny Peng
  • 1,891
  • 4
  • 18
  • 26
  • 7
    That option is selected and working but I want folding for If/else and switch cases... How can I get that ? – Amit Dec 26 '12 at 09:24
  • 1
    C + S + Num / - does a collapse all. I had accidentally hit C + / - and voila no more code folding. Thanks this helped to get it back! – Gishu Sep 11 '14 at 16:27
19

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

Chris Lercher
  • 37,264
  • 20
  • 99
  • 131
15

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

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

by @partizanos and @bummi

Sunil Garg
  • 14,608
  • 25
  • 132
  • 189
Thiago
  • 12,778
  • 14
  • 93
  • 110
11

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.

Paul D. Waite
  • 96,640
  • 56
  • 199
  • 270
mmrs151
  • 3,924
  • 2
  • 34
  • 38
7

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.

James Moore
  • 8,636
  • 5
  • 71
  • 90
3

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".

Starkey
  • 9,673
  • 6
  • 31
  • 51
1

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.

Elijah
  • 21
  • 2
1

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

Preferences > Editors > Structured Text Editors

Enable Folding

Brig
  • 10,211
  • 12
  • 47
  • 71
1

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

0

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.

Kim Wilson
  • 111
  • 1
  • 11
0

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

Akshay Vijay Jain
  • 13,461
  • 8
  • 60
  • 73