Thursday, February 24, 2011

Re: text substitution for all the files opened in vim

On 02/23/2011 11:20 PM, Ben Schmidt wrote:
> On 24/02/11 3:50 PM, Peng Yu wrote:
>> :%s only perform substitution with a file. Is there a command that can
>> perform substitution in all the files that are opened by a vim session?
>
> Check out
>
> :help :argdo
> :help :bufdo

...remembering that vim will complain if you try to leave a
modified buffer unless you

1) save the buffer as part of your command:

:bufdo %s/foo/bar/g|w

2) set 'hidden' to allow vim to leave a modified buffer:

:set hidden
:bufdo %s/foo/bar/g
<review changes to make sure they're what you want>
:wall

-tim

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