mhinz / vim-grepper

:space_invader: Helps you win at grep.
MIT License
1.22k stars 58 forks source link

Grepper in Vimscript function does not execute subsequent cdo command #259

Open gennaro-tedesco opened 2 years ago

gennaro-tedesco commented 2 years ago

I am writing a simple function to search the word under cursor and replace it automatically, something along the lines of

function! Replace() abort
    Grepper -cword -noprompt -noopen
    silent execute "cdo s/" . expand("<cword>") . "/<replace>/g"
endfunction

however, I noticed that when using vim-grepper and Grepper as grep wrapper, the subsequent cdo command is not executed, namely the quickfix windows opens up and no replacement is done. If instead I use the standard vimgrep <cword> % with the above function all works as intended.

I suppose it may have to do with having to use <Plug>(GrepperOperator) in a function rather than Grepper as command, or am I making some other trivial mistake (for instance there are flags to directly execute cdo commands after grepping)?