Friday, December 2, 2011

Re: If I copy multi line text to clipboard how do I know use that in vim for replace text in search/replace?

On Dec 1, 11:49 pm, Rick R <ric...@gmail.com> wrote:
>
> I'm still having trouble with this. I actually want it to replace the text
> in multiple files that aren't opened.

Then, the best way to do it, is using :argdo.

Start by opening a new window. The execute:

:arglocal (pattern or list of files to add)
(:args will also work above but will mess with the global argument
list)
:argdo g/search pattern/put {register name}

Or, for your example:
:args *.html
:argdo g/<body>/put *

> [snip]
>
> Using what you suggested in vim I though maybe I could do something like:
>
> :args *.html
> :argdo g/<body>/put=@*
>

Note your incorrect use of the expression register, instead of the
register you actually want.

> But when try that (and I know in the above I'd lose the <body> tag if it
> worked) all I get is <body> highlighted in the file displayed.
>

You should not lose the <body> tag in this situation. The :g command
does not do a replace, it only performs an action on lines that match.
The action performed in this case, is "paste the contents of register
* below the matched line".

I'm just now re-reading Albin's response, and seeing that he said much
the same thing in fewer words. Sorry for any duplication but maybe
multiple perspectives will help your understanding.

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