Thursday, February 3, 2011

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

On Thu, Feb 3, 2011 at 10:19 AM, Benjamin R. Haskell <vim@benizi.com> wrote:
On Wed, 2 Feb 2011, Colin Beighley wrote:

Hello,
I want to do something like this

word => ,

becomes

word => word,

with search and replace. Any suggestions?

s/\(word\) => ,/\1 => \1,/

--
Best,
Ben

--
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

Thanks! What I wanted was to match any word before the =>, as well as preceding tabs, so I ended up using

:s/\(^\t*\)\t\(.*\) => ,/\1\t\2 => \2,/

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: