Some times, we don't have sed, like windows environment.

--------------------------------------------------
From: "Christian Brabandt" <[email protected]>
Sent: Tuesday, August 11, 2009 8:46 PM
To: <[email protected]>
Subject: Re: Replace Just Needed

> 
> Hi Ricky!
> 
> On Di, 11 Aug 2009, Ricky wrote:
> 
>> One line contains a number of same words:
>> ---
>> I've never saw a saw saw a saw
>> She never saw a saw saw a saw
>> ...
>> He never saw a saw saw a saw
>> ---
>> 
>> I just want to replace the 2nd or 3rd "saw", Do you have any idea? 
> 
> In vim, you could use:
> :s/\(saw.\{-}\)\{2\}\zssaw/foobar
> 
> to replace the third occurance.
> 
> But I would probably filter the lines through sed, since sed makes it 
> easier to select only a particular match. So the following would only 
> match the 3rd saw with foobar:
> 
> :%!sed 's/saw/foobar/3'
> 
> 
> regards,
> Christian
> -- 
> -rwxr-xr-x  1 root          24 Oct 29  1929 /bin/ed
> -rwxr-xr-t  4 root      131720 Jan  1  1970 /usr/ucb/vi
> -rwxr-xr-x  1 root  5.89824e37 Oct 22  1990 /usr/bin/emacs
> 
> > 
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to