On Sat, Mar 29, 2008 at 2:24 PM, SJS <[EMAIL PROTECTED]> wrote:
> begin  quoting Bob La Quey as of Sat, Mar 29, 2008 at 01:52:53PM -0700:
>
> > How does one limit the range of the
>  > vim multiline substitution command?
>  >
>  > i.e.
>  > :%s/that/this/
>  >
>  > will do a global substituion of this for that.
>  >
>  > But say I want to limit the substitution to
>  > say ten lines from the cursor. I tried
>  > :10s/that/this/
>  >
>  > but it does not work.
>  >
>  > How does one do this?
>
>  :s/that/this/10

OK, in this construct, the "10" is a repeat count.
A quick experiment shows it to be a repeat count of lines searched not
of successful searches.  So it means "search the next ten lines for
/that/".  Does not mean "search for the next ten occurrences of
/that/".

>  globally on each line?
>
>  :s/that/this/g10
>
>  Or you can use line numbers
>
>  :11,21s/that/this/
>

There is definitely more than one way to do it.  :-)

My favorite recipe, which lets the computer count the lines so I don't
have to, is:

Navigate to the starting line, place a Mark there (e.g. a)
ma
Navigate to the ending line, perform action between Mark and Dot
(current position)
:'a,.s/that/this/

Mark and Dot sound very much like TECO constructs, come to think of it.

    carl
-- 
 carl lowenstein marine physical lab u.c. san diego
 [EMAIL PROTECTED]


-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to