Referencing Post:
Specifically:
:Ag foo
:Qfdo s/foo/bar/c
I type Ag miwt-os
, I get this:
Which is the terminal, and I am lost her, how do I now get the results into the quckfix to run it through Qfdo?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityReferencing Post:
Specifically:
:Ag foo
:Qfdo s/foo/bar/c
I type Ag miwt-os
, I get this:
Which is the terminal, and I am lost her, how do I now get the results into the quckfix to run it through Qfdo?
You don't need a plugin for using The Silver Searcher — or any other grep alternative — in Vim:
set grepprg=ag\ --nogroup\ --nocolor\ --ignore-case\ --column\ --vimgrep
set grepformat=%f:%l:%c:%m,%f:%l:%m
With those lines in your vimrc
you can simply do :grep miwt-os
to populate the quickfix list with matching lines or :lgrep miwt-os
to populate the location list.
From there you can open the quickfix/location window with either :cw
or :lw
to take a look at the list before going further or directly use :Qfdo
.
If you want the quickfix/location window to be opened automatically, add these lines to your vimrc
:
augroup quickfix
autocmd!
autocmd QuickFixCmdPost [^l]* cwindow
autocmd QuickFixCmdPost l* lwindow
augroup END
ag
with Vim, but sometimes such a plugin can be quite handy. CtrlSF is a good example. FWIW.
Feb 15, 2016 at 21:07
--vimgrep
option uses --nogroup
, --nocolor
, and --column
by default.
Feb 16, 2016 at 1:19
It looks like you have to :AgAdd
instead of just Ag
, which will add the results to quick links.
Use macros to do what you want. Start at the first replacement, :cr
, then... (Comments just for description.)
qbq " clear b register
qa " start recording macro a
:s/old text/new text/
:cn
q " end macro
qb@a@bq " create macro b to call macro a then itself
@b " launch macro b
Watch it tear through your project.
But why you want to do this via Vim? It would be much easier to run ag -l pattern | xargs -n1 sed 's/pattern/replacement/g
in Your shell (or at least via :!
).
.git
directory, you may want to redo the search, or it will invalidate the SHA. Thanks for the comment...
Feb 16, 2016 at 15:26
:Qfdo
via:cdo
.