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

51421Re: BUG: g ignores range in diff mode

Expand Messages
  • Bram Moolenaar
    Aug 5, 2008
    • 0 Attachment
      Gary Johnson wrote:

      > When vim is in diff mode and a BufWrite autocommand containing a
      > "<range>g" is executed, the g command appears to ignore the range
      > and act on the entire buffer.
      >
      > Here's an example.
      >
      > Create a file containing the integers from 1 to 1000, each on a
      > separate line:
      >
      > $ seq 1000 > seq1
      >
      > Create the following vim script and name it "test1.vim":
      >
      > au BufWrite * 1,100g/50$/s/$/\tchanged here/
      >
      > When that autocommand is triggered by writing the buffer, it should
      > append "\tchanged here" to every line in the range 1 to 100 ending
      > in "50". That is, it should change line 50 and only line 50.
      >
      > Now edit seq1 with vim, source the script, open a new buffer, and
      > read seq1 into that buffer:
      >
      > $ vim -N -u NONE -i NONE -c 'so test1.vim' -c 'vnew|r seq1|normal ggdd' seq1
      >
      > There's nothing magic about doing that on the command line--I just
      > got tired of typing all those vim commands as I worked on making the
      > example smaller.
      >
      > Now move the cursor to the right window (^W^W) and write the buffer
      > to the seq1 file by executing:
      >
      > :w
      >
      > Note that line 50 and only line 50 has changed to:
      >
      > 50 changed here
      >
      > This is as it should be.
      >
      > Now diff the two buffers:
      >
      > :windo diffthis
      >
      > and write the right buffer again:
      >
      > :w
      >
      > Note now that every line in the file ending in "50" (i.e., 150, 250,
      > 350, 450, 550, 650, 750, 850 and 950) has been appended with
      > "changed here". This appears to be a bug.

      Not a bug. When folds are closed the operation applies to the whole
      fold. See ":he E493" and scroll up a bit. Or ":he fold-behavior".

      --
      Why isn't there mouse-flavored cat food?

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ download, build and distribute -- http://www.A-A-P.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Show all 6 messages in this topic