Loading ...
Sorry, an error occurred while loading the content.

Folding with syntax

Expand Messages
  • Dany St-Amant
    Hi, I was fool[d]ing around with the folding when I realize that it would be cool if i could also fold the comments (i.e.: it s a little bit annoying to have
    Message 1 of 7 , Sep 5, 2000
    • 0 Attachment
      Hi,

      I was fool[d]ing around with the folding when I realize that it would be
      cool if i could also fold the comments (i.e.: it's a little bit annoying to
      have all the code folded but still having those pages-long comments
      describing the function behaviour of each single procedure) The only problem
      is that the language I use (at work) don't have a start and end of comment
      mark a la C (/* and */) The comment delimiter is % and behave like vim's ".

      So, is there a way to fold all contiguous line matching "^\s*%" into a
      fold? or do we need to implement a ':syntax match "^\s*%.*" join fold' ?

      Is there a way to get each if/elseif/else/endif subregion foldable
      individually?

      e.g (in vim script):

      +-- 3 lines: if has('gui_mac')
      +-- 5 lines: elseif had ('gui_win32')
      +-- 2 lines: else
      endif

      One more thing, if we ever get various "Folded" highlighting setting could
      the folding be enabled/disabled separately. (i.e.: I may what my comment
      unfold and my code totaly folded)

      A last comment, the 'foldcolumn' option should be renamed to something like
      "margin" as it's also usefull for the 'signs' (the pixmap overlap the
      'foldcolumn' instead of hiding the first few characters)

      Dany, who type to often 'xo<ESC>uzo' instead of simply 'zo'
    • David Harrison
      ... I agree with the need for this. I often want comments folded away to keep down the distractions (like when I am removing, say, 5,000 lines of code across
      Message 2 of 7 , Sep 7, 2000
      • 0 Attachment
        On Wed, Sep 06, 2000 at 12:23:34AM -0400, Dany St-Amant wrote:
        >
        > One more thing, if we ever get various "Folded" highlighting setting could
        > the folding be enabled/disabled separately. (i.e.: I may what my comment
        > unfold and my code totaly folded)

        I agree with the need for this. I often want comments folded away to keep down
        the distractions (like when I am removing, say, 5,000 lines of code across
        multiple files & functions... I often comment them out first & then recompile
        & test).

        On a similar note, a co-worker of mine only wants comments highlighted with
        the syntax highlighting, but there is no way to do that without setting the
        highlighting for EVERYTHING, including the comments. He really only wants
        to be able to switch the colors off for everything except comments. You
        cannot do this currently. I feel that this feature will eventually make it
        into Vim in the not too distant future (maybe version 7?) as I think that it
        will alleviate some of the current frustrations with the average user setting
        up syntax highlighting schemes.

        Just my two cents...

        --David Jr.
      • Rafael Garcia-Suarez
        ... A way to get this behavior is to link the highlighting of Constant, Number, Statement, PreProc, Type, Identifier, etc. to Normal in the .vimrc. -- Rafael
        Message 3 of 7 , Sep 7, 2000
        • 0 Attachment
          David Harrison wrote:
          >
          > On a similar note, a co-worker of mine only wants comments highlighted with
          > the syntax highlighting, but there is no way to do that without setting the
          > highlighting for EVERYTHING, including the comments. He really only wants
          > to be able to switch the colors off for everything except comments. You
          > cannot do this currently. I feel that this feature will eventually make it
          > into Vim in the not too distant future (maybe version 7?) as I think that it
          > will alleviate some of the current frustrations with the average user setting
          > up syntax highlighting schemes.

          A way to get this behavior is to link the highlighting of Constant,
          Number, Statement, PreProc, Type, Identifier, etc. to Normal in the
          .vimrc.

          --
          Rafael Garcia-Suarez
        • Bram Moolenaar
          ... You should be able to define a region that starts at the first line that s a comment and stops before the next line that isn t a comment. You will need
          Message 4 of 7 , Sep 20, 2000
          • 0 Attachment
            Dany St-Amant wrote:

            > I was fool[d]ing around with the folding when I realize that it would be
            > cool if i could also fold the comments (i.e.: it's a little bit annoying to
            > have all the code folded but still having those pages-long comments
            > describing the function behaviour of each single procedure) The only problem
            > is that the language I use (at work) don't have a start and end of comment
            > mark a la C (/* and */) The comment delimiter is % and behave like vim's ".
            >
            > So, is there a way to fold all contiguous line matching "^\s*%" into a
            > fold? or do we need to implement a ':syntax match "^\s*%.*" join fold' ?

            You should be able to define a region that starts at the first line that's a
            comment and stops before the next line that isn't a comment. You will need
            the new multi-line regexp stuff for this: The region ends if if there is _no_
            match for a comment in the next line.

            > Is there a way to get each if/elseif/else/endif subregion foldable
            > individually?
            >
            > e.g (in vim script):
            >
            > +-- 3 lines: if has('gui_mac')
            > +-- 5 lines: elseif had ('gui_win32')
            > +-- 2 lines: else
            > endif

            It's difficult with syntax folding, because the whole if-endif would be seen
            as one region, and thus one fold. The simplest would be to use expression
            folding.

            > One more thing, if we ever get various "Folded" highlighting setting could
            > the folding be enabled/disabled separately. (i.e.: I may what my comment
            > unfold and my code totaly folded)

            I don't understand this one...

            > A last comment, the 'foldcolumn' option should be renamed to something like
            > "margin" as it's also usefull for the 'signs' (the pixmap overlap the
            > 'foldcolumn' instead of hiding the first few characters)

            There are still a few problems to be solved for the signs, this probably
            confused you. There is supposed to be a separate column to show the signs,
            the 'foldcolumn' is separate.

            --
            hundred-and-one symptoms of being an internet addict:
            7. You finally do take that vacation, but only after buying a cellular modem
            and a laptop.

            /// Bram Moolenaar Bram@... http://www.moolenaar.net \\\
            \\\ Vim: http://www.vim.org ICCF Holland: http://iccf-holland.org ///
          • Bram Moolenaar
            ... I see the problem. I ll put it in the todo list. ... Hopefully he went to an area without antennas and mains power.... -- Change is inevitable, except
            Message 5 of 7 , Sep 21, 2000
            • 0 Attachment
              Thomas Koehler wrote:

              > Well, as for the problems still to be solved, I have a problem with
              > "wrap" set to on, and "number" or "foldcolumn" (or both) being set...
              > The gj and gk command take me to the wrong place, or, in other words,
              > the "showbreak" option does no longer work as it did before, but vim
              > calculates things as if it would...

              I see the problem. I'll put it in the todo list.

              > > hundred-and-one symptoms of being an internet addict:
              > > 7. You finally do take that vacation, but only after buying a cellular
              > > modem and a laptop.
              >
              > *veg* My boss just went on vacation a week ago, having a laptop and a
              > cellular modem in his luggage :-)

              Hopefully he went to an area without antennas and mains power....

              --
              Change is inevitable, except from a vending machine.

              /// Bram Moolenaar Bram@... http://www.moolenaar.net \\\
              \\\ Vim: http://www.vim.org ICCF Holland: http://iccf-holland.org ///
            • Thomas Köhler
              On Wed, Sep 20, 2000 at 04:44:32PM +0200, ... [...] ... Well, as for the problems still to be solved, I have a problem with wrap set to on, and number or
              Message 6 of 7 , Sep 27, 2000
              • 0 Attachment
                On Wed, Sep 20, 2000 at 04:44:32PM +0200,
                Bram Moolenaar <Bram@...> wrote:
                >
                >
                > Dany St-Amant wrote:
                >
                [...]
                > > A last comment, the 'foldcolumn' option should be renamed to something like
                > > "margin" as it's also usefull for the 'signs' (the pixmap overlap the
                > > 'foldcolumn' instead of hiding the first few characters)
                >
                > There are still a few problems to be solved for the signs, this probably
                > confused you. There is supposed to be a separate column to show the signs,
                > the 'foldcolumn' is separate.

                Well, as for the problems still to be solved, I have a problem with
                "wrap" set to on, and "number" or "foldcolumn" (or both) being set...
                The gj and gk command take me to the wrong place, or, in other words,
                the "showbreak" option does no longer work as it did before, but vim
                calculates things as if it would...

                Here's an example, uppercase characters show the cursor position:

                +-----------+ +-----------+ +-----------+
                |#this is lo| |#this is lo| |#tHis is lo|
                |#ng line th| hit |#ng Line th| |#ng line th|
                |#at wrAps |=======>|#at wraps | |#at wraps |
                |# | gk |# | |# |
                |# | |# | |# |
                +-----------+ +-----------+ +-----------+
                ^- foldcolumn ^- foldcolumn ^- foldcolumn

                So, gj and gk show strange behaviour here.
                Setting the number options makes things worse...

                > hundred-and-one symptoms of being an internet addict:
                > 7. You finally do take that vacation, but only after buying a cellular modem
                > and a laptop.

                *veg* My boss just went on vacation a week ago, having a laptop and a
                cellular modem in his luggage :-)

                Ciao,
                Thomas

                --
                Thomas Köhler Email: jean-luc@... | LCARS - Linux
                <>< WWW: http://jeanluc-picard.de | for Computers
                IRC: jeanluc | on All Real
                PGP public key available from Homepage! | Starships
              • Thomas Köhler
                On Thu, Sep 21, 2000 at 07:06:02PM +0200, ... OK. I d like this one to be fixed some time, because I always have number and foldcolumn on :-) ... No, he
                Message 7 of 7 , Sep 29, 2000
                • 0 Attachment
                  On Thu, Sep 21, 2000 at 07:06:02PM +0200,
                  Bram Moolenaar <Bram@...> wrote:
                  > Thomas Koehler wrote:
                  >
                  > > Well, as for the problems still to be solved, I have a problem with
                  > > "wrap" set to on, and "number" or "foldcolumn" (or both) being
                  > > set... The gj and gk command take me to the wrong place, or, in
                  > > other words, the "showbreak" option does no longer work as it did
                  > > before, but vim calculates things as if it would...
                  >
                  > I see the problem. I'll put it in the todo list.

                  OK. I'd like this one to be fixed some time, because I always have
                  "number" and "foldcolumn" on :-)

                  > > > hundred-and-one symptoms of being an internet addict:
                  > > > 7. You finally do take that vacation, but only after buying a cellular
                  > > > modem and a laptop.
                  > >
                  > > *veg* My boss just went on vacation a week ago, having a laptop and a
                  > > cellular modem in his luggage :-)
                  >
                  > Hopefully he went to an area without antennas and mains power....

                  No, he went to an area where he had antennas et al... bad luck, I have
                  his "city call" for that time, and this one always beeps when someone
                  tries to phone my boss while his cellular phone is powered off. Much of
                  beeping here while my boss is on the beach :-}

                  Ciao,
                  Thomas

                  --
                  Thomas Köhler Email: jean-luc@... | LCARS - Linux
                  <>< WWW: http://jeanluc-picard.de | for Computers
                  IRC: jeanluc | on All Real
                  PGP public key available from Homepage! | Starships
                Your message has been successfully submitted and would be delivered to recipients shortly.