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

Filtering under folds

Expand Messages
  • Teemu Ikonen
    Filtering a line which is currently folded results in the whole fold being filtered. For example, take a 2-line file like below with set foldmethod=marker: one
    Message 1 of 4 , May 21 12:58 PM
    • 0 Attachment
      Filtering a line which is currently folded results in the whole fold being filtered. For example, take a 2-line file like below with set foldmethod=marker:

      one {{{1
      two

      Issuing the command ':2!echo "foo"', when the fold is open works as expected, the line 'two' is replaced with 'foo'.

      When the fold is closed, after issuing the command both lines are replaced with a single line 'foo'.

      Is this a bug or a feature? If the latter, how can I make the filtering work as expected, when folds are closed?

      (I'm using vim 7.4.273 from Debian)

      Best,
      Teemu

      --
      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.
    • Manuel Ortega
      ... It s a documented aspect of Vim. When an ex command is applied to a line in a closed fold, the command is applied to every line in the fold. See :h
      Message 2 of 4 , May 21 4:55 PM
      • 0 Attachment
        On Wed, May 21, 2014 at 2:58 PM, Teemu Ikonen <tpikonen@...> wrote:
        Filtering a line which is currently folded results in the whole fold being filtered. For example, take a 2-line file like below with set foldmethod=marker:

        one {{{1
        two

        Issuing the command ':2!echo "foo"', when the fold is open works as expected, the line 'two' is replaced with 'foo'.

        When the fold is closed, after issuing the command both lines are replaced with a single line 'foo'.

        Is this a bug or a feature? If the latter, how can I make the filtering work as expected, when folds are closed?

        It's a documented aspect of Vim.  When an ex command is applied to a line in a closed fold, the command is applied to every line in the fold.  See :h fold-behavior.

        As for solving your problem, I'm not sure.  Possibly you could use a custom command or function that temporarily opens the fold, performs the filtering, and then refolds.  Possibly you could use getline() and friends to put the target line(s) into a tempfile, perform the necessary operations, and setline() it back in.

        -Manny 

        --
        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/d/optout.
      • Ingo Karkat
        ... I would use :set nofoldenable | ... | set foldenable for that, or the zi normal mode command to toggle. -- regards, ingo -- -- You received this message
        Message 3 of 4 , May 22 12:54 AM
        • 0 Attachment
          On 22-May-2014 01:55 +0200, Manuel Ortega wrote:

          > On Wed, May 21, 2014 at 2:58 PM, Teemu Ikonen <tpikonen@...
          > <mailto:tpikonen@...>> wrote:
          >
          > Filtering a line which is currently folded results in the whole fold
          > being filtered. For example, take a 2-line file like below with set
          > foldmethod=marker:
          >
          > one {{{1
          > two
          >
          > Issuing the command ':2!echo "foo"', when the fold is open works as
          > expected, the line 'two' is replaced with 'foo'.
          >
          > When the fold is closed, after issuing the command both lines are
          > replaced with a single line 'foo'.
          >
          > Is this a bug or a feature? If the latter, how can I make the
          > filtering work as expected, when folds are closed?
          >
          >
          > It's a documented aspect of Vim. When an ex command is applied to a
          > line in a closed fold, the command is applied to every line in the fold.
          > See :h fold-behavior.
          >
          > As for solving your problem, I'm not sure. Possibly you could use a
          > custom command or function that temporarily opens the fold, performs the
          > filtering, and then refolds. Possibly you could use getline() and
          > friends to put the target line(s) into a tempfile, perform the necessary
          > operations, and setline() it back in.

          I would use :set nofoldenable | ... | set foldenable for that, or the
          "zi" normal mode command to toggle.

          -- regards, ingo

          --
          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.
        • Teemu Ikonen
          ... Thanks Ingo, toggling foldenable seems to do what I want. Best, Teemu -- -- You received this message from the vim_dev maillist. Do not top-post! Type
          Message 4 of 4 , May 22 8:10 AM
          • 0 Attachment
            On Thursday, May 22, 2014 9:54:36 AM UTC+2, Ingo Karkat wrote:
            > I would use :set nofoldenable | ... | set foldenable for that, or the
            >
            > "zi" normal mode command to toggle.

            Thanks Ingo, toggling foldenable seems to do what I want.

            Best,
            Teemu

            --
            --
            You received this message from the "vim_dev" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php

            ---
            You received this message because you are subscribed to the Google Groups "vim_dev" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/d/optout.
          Your message has been successfully submitted and would be delivered to recipients shortly.