20

There is a nice feature in Visual Studio: you can create special code areas which can be minimized just as class methods in Eclipse are minimized. Like:

#region

//some code

#endregion

Is there a way do make such pleasant feature in Eclipse?

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
Stella
  • 465
  • 3
  • 8
  • 15
  • 4
    Code-folding is like cleaning up a house by putting all the junk in one room and closing the door. You haven't really accomplished anything, you're just fooling yourself and others that your code (house) is now clean. – JesperE Dec 21 '08 at 07:35
  • 3
    Code-folding is **sometimes but not all times** like cleaning up a house by putting all the junk in one room and closing the door. – Pacerier Dec 03 '11 at 08:42
  • Coffee-Bytes for Eclipse 3.6 & higher: http://stackoverflow.com/questions/8534542/what-code-folding-plugins-work-on-eclipse-3-6 – Yaqub Ahmad Jan 03 '12 at 07:48
  • The term you're looking for is *code-folding*. A cursory Web search turns up the [Coffee-Bytes](http://www.realjenius.com/platform_support) plug-in to add folding support beyond the built-in options. [Reviews are mixed.][2] [2]: http://www.eclipseplugincentral.com/Web_Links-index-req-viewlink-cid-269.html – Rob Kennedy Dec 20 '08 at 21:59
  • Code-folding is also sometimes like cleaning up a kitchen by putting appliances in one cupboard, fresh produce in the refrigerator, and canned stuff in the pantry. Could you make these separate classes? Sure, but sometimes that's a bit too much like putting walls through the middle of your kitchen. Any other code-folding simile contributions? ;) – andrewb Feb 14 '14 at 22:43

7 Answers7

12

It's called "collapse all", click on the editor view that you want to collapse all your methods in go to help> key assist...> double click "collapse all">, everything is collapsed

Mitch
  • 121
  • 1
  • 2
  • 2
    This might not directly answer the question, but it certainly is helpful for the methods and comments that are already collapsible. Thanks – tgrosinger Apr 26 '11 at 20:41
5

Click on ' - (minus)' symbol on the side of the editor, Right click on minus symbol , Go to folding / Collapse All

Keyboard shortcut : Ctrl+Shift+NumbPad_Divide

arthi
  • 59
  • 1
  • 1
4

First check Folding is enable or disable if enabled then you can minimize or collapse code and expand code. You can check Folding through

Folding is configured under Window -> Preferences -> Java -> Editor ->Folding

Please check Enable Folding if its unchecked

Now you can minimize your code

Collapse All (all functions on page) : Ctrl+Shift+NumbPad_Divide

Expand All (all function on page) : Ctrl+Shift+NumbPad_Mulitply

Collapse One function : Ctrl+NumbPad_Minus

Expand One Function : Ctrl+NumbPad_Plus

Zeeshan
  • 1,625
  • 17
  • 25
3

If you mean by minimizing folding, then I don't think Eclipse has the folding option you want. When I look at the eclipse folding options it tells me that it can fold

  • Comments
  • Header Comments
  • Inner Types
  • Members
  • Imports

If you don't mean folding, then I'm sorry for the confusion.

Stefan Schmidt
  • 1,152
  • 11
  • 18
0

There are some plugins for this, like "Coffee Bytes Java Folding" for Eclipse. Other IDE like Netbeans as an native equivalent.

It's really IDE dependent in Java, not implemented in the language like in C# for example.

0

Java Equivalent to #region in c#

Check the second answer

//region MY REGION

code here

//endregion

Community
  • 1
  • 1
-11
  • Heres how I do it:

    1. Create an empty class called Blank
    2. Use this outline for your code:

    Blank b = new Blank() { public void myCode() { /Insert code here/ } }; b.myCode();