#18 Code Folding / Collapsing

Jochen Ruehl

I'm moving over from Komodo as on the whole, eclipse
seems to be a lot fuller featured.
One thing I'd love to see in EPIC though is the ability
to fold blocks of code (with + and - icons) so that an
"if" block can be collapsed, for example.


  • H Kitchin
    H Kitchin

    Logged In: YES

    +1 vote for this.

    Now that eclipse 3.0 supports folding is there an ETA for
    EPIC handling it?

  • LeO

    Logged In: YES

    The new version has code-folding for Subs only.

    Is this really required for 'if'-statements, cause in
    Eclipse it's not included? And what way should it be

  • Logged In: YES

    I would appreciate it for if-statemets too, 'cause I often
    have constructs like:

    #-- describe following if-statement
    if( defined $me ) {
    # ..

    so this would be like

    #-- describe following if-statement
    if( defined $me ) {

    Just with an arrow in front. A possible solution to differ
    sub's and if's from each other would it be to define
    different colors for both. You could easily distinguish both
    if, say, the color of the if-arrow is slightly brighter than


  • LeO

    • assigned_to: nobody --> luelljoc
  • LeO

    Logged In: YES

    Hm', I personally see that one with an IF-ELSE little
    tricky. Cause this could cause a lot of work for the
    programmers on the one side, and for Eclispe on the other
    side. eg. we should distinguis beween

    # if ($test) {




    if (test) {

    etc. (including bracket-matching)

    So, perhaps the most reasonable approach might be to have a
    right-click option with "Fold mark area" or similar.

  • Logged In: YES

    Makes sense. Personally I love the #TODO style adding to the
    task-list. Maybe one could create #FOLD or #BLOCK parts. The
    most tricky thing that I see /is/ "bracket matching", like:

    if( cond1 ) {
    for( @array ) {
    if( great_enough ) {

    I'm afraid this would get way more complicated than I
    thought in first moment.


  • shiraz

    Logged In: YES

    I would also love to see EPIC do code folding. It is very
    irretating to see that code folding works in java
    perspective in eclipse 3.0 and not having this cool feature
    in perl perspective.

  • LeO

    Logged In: YES

    since there seems to be more interest in this issue, perhaps
    we can specify it little bit more in detail. Generally speaking
    the codefolding works for subs, but what more is requested?

    Bracketmatching is already there, so this peace of code could
    be easily used.

    Parametrized? If so, then ignoring commented stements,
    under quotes, pods etc? Should this be done automatically?
    Problems I would see at the quick glance eg.

    $aifz = ... {
    which I guess should not be folded when you have
    specified 'if' but given the code of phaylon it should -
    although after the 'if' there is no space at all!

    How to specify the parameter for e.g. 'if' in contrast to e.g.

    The more I think, the complicated the issue gets. Hm', but
    perhaps there is a missing concept what should be achieved.
    Perhaps we could generate some samples, and then say,
    what should happen. Could be done as well offline.

  • Logged In: YES

    | The more I think, the complicated the issue gets. Hm',
    | but perhaps there is a missing concept what should
    | be achieved.

    Hm, this is your backyard. I'm sorry to tell that I have no
    clue how things for eclipse are developed. Do these features
    make use of regular expressions?

    I lately thought about this and got a few idea, but I don't
    know if they may help you. One thing I thought of (if it
    uses regex'es) would be to say one can only fold blocks
    larger than n lines.

    To the question /what/ to fold I reply: I would find it
    mostly useful on if and unless blocks. Most times I want to
    fold away things like Error-Handling, Special cases and
    such. Loops, I think, are more "significant"(sry, not an
    english speaker, lack of a better word..) for the actual

    | Perhaps we could generate some samples,
    | and then say, what should happen. Could
    | be done as well offline.

    I'll think over it for the weekend. You're reading your
    sf.net mail?

    so long,

  • shiraz

    Logged In: YES

    If I had the BNF Grammar of perl, i would be able to more
    formaly say what needs to be folded. But conceptually any
    thing which is of type "BLOCK" , should have the ability to be
    Any construct which has the beginning and end should be
    able to fold. Like for exampe, all the loops, if-then-else
    construct, subroutine( this is already there in epic) and such.

    The concept of folding is new to the intellegent IDE world and
    would take some time for us programmer to fully understand
    the benefit of it. But for those who are maintining someone
    else code which is thousands of line long, this feature is a

  • Logged In: YES

    The best Idea is to fold with rightclick on the item to be

    eg. Brakets, or all possible constructs the compiler sees as
    corresponding tokens (if ..else, ...)

    The automated generation of such templates eg. a list of
    possiblities arises and I use the lasso-Function of the
    mouse, and the [Ctrl]+left mouse button to collect what i
    need as statement.

    That would be a nice feater fo input, and would also
    generate the data needed for folding.

    If there are more possiblities to fold or unfold:
    doubleclick unfolds all, right click let you chouse how many
    layers or sections you want to unfold:
    if( cond1 ) {
    for( @array ) {
    if( great_enough ) {

    this folded:
    if (cond1) [..]

    unfolding 1 layer:
    if( cond1 ) {
    for( @array ) [..]

    and so on.

    with regards

    (I just started learning java, such a task is too hard for
    me - in the moment ;-)

  • Logged In: NO

    Voting for bracket folding. If the programmer has added
    block brackets, then they've indicated manually that a chunk
    of code is a candidate for collapse. This would be a
    godsend for nastily branching logic trees.


  • Kevin Benton
    Kevin Benton

    Logged In: YES
    Originator: NO

    Jochen, I agree, being able to fold more than subroutines would be helpful. Making it possible to fold any multi-line block would greatly increase the usability of collapsible code. :-) I too am considering leaving Komodo behind, though the jury is still out at the moment.

  • This would be a wonderful addition to an already great IDE. After using EPIC for months, the only thing that lacks is more bracket folding.


  • Anonymous

    Man this is an old request! I would also like if block code folding.


  • Anonymous

    Is anyone actively looking into this issue?

  • Jan Ploski
    Jan Ploski

    AFAIK, noone is actively looking into this issue, you're welcome to give it a try and submit patches.