On 22/05/09 09:15, John Beckett wrote:
>
> Mahendra Ladhe wrote:
>> I've opened say 20 files using one vim instance. I want to
>> do the same sequence of operations on all files as below.
>> 1. Replace occurrences of one word by some other word 2..
>> Save the file 3. Delete it from buffer so that some other
>> file becomes current.
>>
>> Repeat above process till buffer becomes empty.
>> Can I club all these actions at vim command line?
>> something like
>> :s/one_word/another_word/g;w;bd
>
> A better approach is to NOT close each file (you probably want
> to go back and admire each), so set option allowing you to have
> multiple changed buffers:
>
>    :set hidden
>
> To substitute in all buffers:
>
>    :bufdo %s/one_word/another_word/g
>
> When finished (and want to exit all):
>
>    :xa
>
> John

Setting 'hidden' is not necessary, just save modified files as part of 
the bufdo:

        :bufdo %s/one_word/another_word/ge | update

Then :qa to quit, or do whatever else you want to do next. (The e flag 
avoids the error if there is no match in some file.)


Best regards,
Tony.
-- 
Gray's Law of Programming:
        n+1 trivial tasks are expected to be accomplished in the same
time as n tasks.

Logg's Rebuttal to Gray's Law:
        n+1 trivial tasks take twice as long as n trivial tasks.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to