Saturday, January 2, 2010

Re: bufdo broken in 7.2.325?

On 02/01/10 13:59, Chris Sutcliffe wrote:
>> Unless you have 'hidden' 'autowrite' or 'autowriteall' set, your first
>> command will refuse to |abandon| the modified buffer (see ":help abandon").
>> You should have done:
>>
>> :bufdo %s/2009/2010/ge |update
>
> I tried ':bufdo! %s/2009/2010/ge' and it behaved as expected (hiding
> the buffers that were modified).

that's if 'hidden' is set; but maybe it wasn't set before? I don't use
'hidden' myself because I don't like having unsaved files out of sight
(but then, I use 'autowriteall' so it would have worked for me, saving
all files except maybe the last one which would remain open).

>
>> -- and BTW, beware that the above will also change 120090 to 120100.
>
> Good point. How do I search for white space before and after the 2009
> and replace it with 2010 saving the white space?

You could search for word boundaries: %s/\<2009\>/2010/ge where \< means
"start of word" and \> means "end of word" (both are zero-length matches).

>
> Thank you all for your replies.
>
> Chris
>

Best regards,
Tony.
--
"Why isn't there a special name for the tops of your feet?"
-- Lily Tomlin

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

No comments: