Friday, January 1, 2010

Re: bufdo broken in 7.2.325?

> I was in the process of updating the copyright date for a whole bunch
> of my source files that I had open in buffers in vim. I tried:
>
> :bufdo %s/2009/2010/ge
>
> All it did was update the first buffer.
>
> Did I do something wrong with bufdo, or is it broken?

Using bufdo requires leaving ("abandoning") the buffer. If
you've made changes, you either need to write them as part of
your command:

:bufdo %s/foo/bar/ge | update

or you have to

:set hidden

to allow vim to leave the modified buffer while preserving the
changes. I didn't see mention of either in your email, so my
guess would be that either one will solve the issue. I prefer
the 'hidden' method so I can go back and review my changes before
issuing a

:wall

to write them, just in case I did something bone-headed.

You might also be able to use 'autowrite' or 'autowriteall', but
I prefer to have greater control over my writes, so I dislike
those options.

:help abandon
:help 'hidden'
:help bufdo

for more info on the peculiarities.

-tim


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

No comments:

Post a Comment