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

Re: Deleting lines from L1 to L2 in Vim script

Expand Messages
  • A.J.Mechelynck
    ... Similarly, in a range, a dot means the cursor line. Thus, to delete from the cursor line to the end of the file, use .,$d (dot comma dollar d-for-delta).
    Message 1 of 7 , May 30, 2006
    • 0 Attachment
      Tim Chase wrote:
      >> And how about deleting from line L1 for instance to the end of
      >> the file. And put it in a script file, since "G" don't appear
      >> like a regexp and $ represent end of line if I'm not wrong ?
      >
      >
      > $ represents the end-of-line in *normal* mode. As an Ex command, it
      > means the last line in the file. Thus, you'd use
      >
      > :42,$d
      >
      > to delete from line 42 to the end of the file.
      >
      > I highly recommend reading the help found at
      >
      > :help :range
      >
      > where you'll learn all sorts of handy ways for referring to lines in
      > an ex command. Commands/addresses can be chained so you can end up
      > with things like
      >
      > :1/APPENDIX/?CHAPTER?+2
      >
      > which would refer to "two lines after (+2) the line that contains
      > "CHAPTER" that occurs before the first line containing the word
      > "APPENDIX". All sorts of complex references and ranges can be created
      > from a few simple addressing schemes.
      >
      > -tim
      >
      >
      >
      >
      Similarly, in a range, a dot means the cursor line. Thus, to delete from
      the cursor line to the end of the file, use

      .,$d

      (dot comma dollar d-for-delta).

      Or, from two lines above the cursor to three lines below the cursor:

      .-2,.+3d

      etc.


      Best regards,
      £Tony.
    Your message has been successfully submitted and would be delivered to recipients shortly.