Thursday, February 24, 2011

Re: text substitution for all the files opened in vim



On Thu, Feb 24, 2011 at 6:33 AM, Christian Brabandt <cblists@256bit.org> wrote:
On Thu, February 24, 2011 1:03 pm, Tim Chase wrote:
> On 02/23/2011 11:20 PM, Ben Schmidt wrote:
>> :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

or
3) set 'autowriteall' which will automatically write your unsaved
  changes. (Not that I think it is a good idea...)

Also, I am sure you know this and not exactly what you are looking for, but I have found using vimgrep and then using the cw command to show matches in a window, then making the edits manually or on per file basis. I came recently from textmate and used global replace a lot but in the end I think I end up messing up things more and that by at least having to go instance by instance in the end save time and get more accurate --

ie.

:vimgrep /findtext/gj ./**
:cw
 

regards,
Christian

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

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

Post a Comment