Thursday, February 3, 2011

Re: Copying and inserting a word in a search/replace

On Wed, Feb 2, 2011 at 10:12 PM, Israel Chauca F. <israelvarios@fastmail.fm> wrote:

On Feb 2, 2011, at 11:37 PM, Colin Beighley wrote:

> Hello,
>
> I want to do something like this
>
> word => ,
>
> becomes
>
> word => word,
>

:%s/^word\ze => ,/& => &,/

%   => whole file
^   => Beginning of line
\ze => end of text to be replaced
&   => matched text

Replace 'word' with '\w\+' or '\a\+', see  :h \w  for more options.

Israel

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

This gives me 

word => word, => ,

Any way to do it without the trailing \s=>, ?

Colin 

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment