I would like to to delete line from L1 to L2, I try to script
that but obviously commands are different for a script. What
is the right thing to do ?


Well, if L1 and L2 represent fixed line numbers, such as "line 24 through line 38", you can just put

        24,38d

in your script.  Quick, easy, clear...the way to go.

If L1 and L2 represent strings/regexps for finding a given line, you can use

        let oldWS=&wrapscan
        set wrapscan
        $/L1/,/L2/d
        let &wrapscan=oldWS

You can skip the 'wrapscan' stuff if you already have 'wrapscan' enabled (most folks do, only to turn it off selectively on an as-needed basis), or if you know that the L1 won't happen on the first line of the file. In the second case (L1 isn't on the 1st line of the file), you can just do

        1/L1/,/L2/d

It basically is searching from line 1 for the first instance of L1, and then deleting through the first instance of L2 that follows L1.

Just a few ideas. I can expound on their magic further if you need, but you can start by reading in the help under

        :help :range
        :help :d

which should get you off to a good start.

-tim


Reply via email to