Last Updated: June 24, 2016
·
239
· ryrych

Project-wide search and replace in Vim with Qargs

Project-wide search and replace in Vim is a bit clumsy, but with vim-qargs it’s a bit easier to pull off.

Suppose that you want to replace all foo with cliché bar. With Qargs you can do this in the following way:

:Ag foo -w app/ -G .js$
:Qargs

ag, grep or any searcher keeps found terms in quickfix list. In order to fire the replacement (with %S/foo/bar) first you have to move the found terms to argument list-you cannot operate on quickfix this way.

argdo %S/foo/bar/gc | update

For convenience you can pull it off in two steps:

:Ag foo -w app/ -G .js$
:Qargs | argdo %S/foo/bar/gc | update