[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vim
Subject:    Re: search and replace
From:       "Chris Allen" <c.d.allen () gmail ! com>
Date:       2006-03-30 16:08:42
Message-ID: 9737d1260603300808y54213c2fqf5fb3c2b6f603e5d () mail ! gmail ! com
[Download RAW message or body]

On 3/30/06, Toni Baker <toni.baker@sbcglobal.net> wrote:
> say I want to replace all occurences of @var with @ub
> in a file.  I would do it with this:
>
> :%s/@var/@ub/g
>
> How could I get this to work if I wanted it to prompt
> me at each ocurrence before changing it?

Add a 'c' after the 'g' flag.  See also :help :s_flags

> Is there a way to do this that is not global?

Certainly, you can change the % to any valid range, such as :1,4s
which would only do it on lines 1 through 4, or :.,$s which would do
it from the current line to the end of the file.  This is a very
flexible system which can do a lot of other stuff.  See :help
cmdline-ranges

HTH,
Chris Allen

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic