MatrixOfNothing has asked for the wisdom of the Perl Monks concerning the following question:

I'm sitting here trying to sift through some inherited code, and getting lost in the levels of logic of if...else nesting things. So I thought, "Wouldn't it be nice if my text editor let me click on a brace and collapse everything up to the closing brace?" Like an explorer thing. Ctrl-B to find pairs of braces just doesn't cut it for lengthy code. Any suggestions? Is there a WinNT editor that does this?

Replies are listed 'Best First'.
Re: Text editor with collapsible braces??
by clemburg (Curate) on Oct 13, 2000 at 22:50 UTC

    Emacs will indent your code according to your preferences. This will definitively help with some of these problems.

    Christian Lemburg
    Brainbench MVP for Perl
    http://www.brainbench.com

RE: Text editor with collapsible braces??
by princepawn (Parson) on Oct 13, 2000 at 23:28 UTC
    I was going to include the code, but it is 60K long. You can pick up folding.el here

    It will take your source code and replace each bracketed section with a marker. You use the navigation commands on the folding mode to move in and out of "folds".

    It worked for me on my C code fine. I haven't used it with Perl, but given that the same character is used for delimited code blocks, there is a good chance.

    It is not a standard part of GNU Emacs (even though my Landmark Learning Neural Network is --- just type meta-x lm-test-run on any GNU Emacs!).

    If you still get no help, take a look through the archives of gnu.emacs.sources or post to gnu.emacs.help or look through The Emacs Lisp Archive

Re: Text editor with collapsible braces??
by Fastolfe (Vicar) on Oct 13, 2000 at 22:45 UTC
    I'm sure most any decent IDE under NT will give you some good features for finding matching parens and braces. Unfortunately the only knowledge I have is of the Unix world. Stock vi will jump to the matching paren/brace/bracket if you hit the percent (%) key. Also, vim ("improved") has some color features that highlight unmatched parens/braces/brackets.
      The so-far-vapour (well, not really -- there are betas and maybe even NT ports at everybody's favorite site, vim.org) vim version 6 is supposed to bring code 'folding' which would do exactly what the poster was looking for.

      Philosophy can be made out of anything -- or less

Re: Text editor with collapsible braces??
by nop (Hermit) on Oct 14, 2000 at 16:17 UTC
Re: Text editor with collapsible braces??
by $code or die (Deacon) on Oct 15, 2000 at 18:15 UTC
    I don't know of a Win editor that collapses braces, but UltraEdit 32 highlights the everything between matching braces when you press ctrl-B.

    Its not perfect, but it's a nice little editor.