I've written about one possible workflow for doing project-wide search/replace in Vim.
This relies on a custom :Qargs
command, which populates the arglist with each of the files listed in the quickfix list.
Having run that command, you can then run :argdo sub/find/replace/gc
to substitute across all files in the argument list.
If only Vim provided a built-in :cdo
command then this workflow would be more straightforward, and wouldn't require the custom :Qargs
command.
Good news: Yegappan has implemented :cdo/:ldo/:cfdo/:lfdo commands. You can read the discussion and find the patch on the vim-dev mailing list.
Here are the steps that I used to download Vim source, apply the patch, and build Vim using the patched source code.
Download Vim's source from GitHub and check out a branch:
git clone [email protected]:vim/vim.git
cd vim
git checkout -b cdo-patch
Download the patch that you want to test and save it to the vim directory. Suppose we're working with a patch called cdo.diff
, we can apply the patch by running:
patch -p1 < cdo.diff
Commit any changed files (and new files):
git add -u
git add new/file.c new/file.h
g ci -m 'Apply cdo.diff patch'
Build Vim:
./configure \
--with-features=huge \
--enable-rubyinterp \
--enable-pythoninterp \
--enable-perlinterp
sudo make && sudo make install
That installs Vim to /usr/local/bin/vim
, overwriting the existing binary.
Thanks @fwalch, that's fixed now.