14

I dislike Eclipse's code folding feature, because the folding state isn't saved when you close the file, like Visual Studio does with its #region directives.

Does anyone know of a plugin which saves the status of the code folding per file, so that when I open it, the code stays folded?

15
  • not sure but i think thats not supported yet.
    – fmucar
    Jul 29, 2011 at 12:30
  • Am I the only one who thinks this is completely silly? I mean, the feature's been there for more than 2 years! I cannot, for the life of me, fathom how they could imagine anybody would like to fold code every time he/she opens a file (well, at least those who like code folding. I can live without it, but sometimes its helpful, especially in big resource files). Their "implementation" of this feature is revolting me ::- D. It's like those applications which don't remember their window position when you closed them and reopen them. Oh well......
    – Axonn
    Jul 29, 2011 at 12:32
  • 2
    and honestly I have never needed that feature at all. Perhaps it's the same with most people, and so it's underdeveloped
    – Bozho
    Jul 29, 2011 at 12:33
  • 1
    I would say if the file is really big, there is probably sth wrong :)
    – fmucar
    Jul 29, 2011 at 13:26
  • 3
    Hey guess what!? Eclipse is an open source project!! Stop crying and contribute to it if you really want such feature!
    – greydet
    Jul 29, 2011 at 13:28

2 Answers 2

10

Try to use: http://code.google.com/p/coffee-bytes/

You have to download the source code, import project into Eclipse and build it. After that Export code as a deployable plug-in for Eclipse. You will have a package for installation.

  1. Install it into Eclipse.
  2. Go To Eclipse Preferences...
  3. Type in search "Folding"
  4. Select Java->Editor->Folding
  5. Select in ComboBox "Coffee Bytes Java Folding"
  6. On General Tab set checkbox - "User Defined Regions"
  7. In User Defined Regions tab - enter #region as a start tag and #endregion as an end tag

In code folding will be available after setting special comments into it:

// #region
... some code ...
// #endregion
5
  • Interesting. Thank you. But isn't this provided as an already compiled Eclipse plugin somewhere?
    – Axonn
    Nov 18, 2011 at 22:09
  • 1
    I followed the instructions in Bartosz Kosarzycki's blog (kosiara87.blogspot.com/2011/12/…), and it seems to be working fine in my Juno 4.2 Eclipse. BTW, does anyone know what the "Type Settings" section in the "User Defined Regions" tab in the Folding preference is all about?
    – vanmelle
    Jul 3, 2013 at 1:04
  • 1
    I created an update site that works with Eclipse Neon: github.com/stefaneidelloth/EclipseFolding/raw/master/…
    – Stefan
    Feb 12, 2017 at 13:38
  • @Stefan: can you please describe, how to use your plugin? I need this feature. Thanks.
    – sarwar026
    Apr 29, 2020 at 13:45
  • Help => Install new Software => Work with github.com/stefaneidelloth/EclipseFolding/raw/master/… After Installation of the plugin follow the instructions from the above answer about the Eclipse Preferences. Does that help?
    – Stefan
    Apr 29, 2020 at 15:19
0

If you are using CDT plugin for eclipse (which means you use C/C++ as your programming language), you may find this is very helpful:

http://syncor.blogspot.com/2011/02/folding-c-code-regions-in-eclipse.html

don't know if Java has a similar feature

1
  • 1
    I didn't install your suggestion, but I do use Java. What happens is is that Eclipse allows code to be folded at every label level, but when a file is closed, it does not keep a record or which methods were folded and which were expanded. In the method that you are suggesting, does it remember which methods are folded and unfolded? Apr 26, 2013 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.