Thursday, December 17, 2015

RE: Search & replace

I think the following pattern shoud work

:%s/Figure of \(.*\) =/\0 \1/g


> Date: Thu, 17 Dec 2015 22:52:47 -0800
> From: whereismelvin@gmail.com
> To: vim_use@googlegroups.com
> Subject: Search & replace
>
> Hi,
>
> I wanted to search & replace a particular pattern like below
>
> Replace
>
> Figure of xx =
> Figure of yyy =
> Figure of ghd =
> Figure of yry =
>
> with
>
> Figure of xx = xx
> Figure of yyy = yyy
> Figure of ghd = ghd
> Figure of yry = yry
>
> I am looking at a command similar to below:-
>
> :1,$ s/Figure of .* = /\0
>
> What I intended was the .* will pick up the characters between "Figure of" & "=" & put it in \0, but looks like \0 takes the value of entire search string. Is there some smart command where I can achieve the above search & replace?
>
> Thanks for the advance help.
>
> --
> --
> 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
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment