I'm trying to create a function that implements the functionality outlined here: Vim search replace all files in current (project) folder
My current attempt:
nnoremap <C-F> :call ReplaceAcrossAllFiles(
function! ReplaceAcrossAllFiles(search, replace)
execute "vimgrep /" . a:search . "/gj | copen "
\ . " | cfdo %s/" a:search . "/" . a:replace . "/gc"
\ . " | cfdo update"
endfunction
If, for example, I execute ReplaceAcrossAllFiles("hi", "hello")
I get E683: File name missing or invalid parameter
EDIT
Thank you @Garcys and @statox for your answers.
I now get an error which I believe is related to the quickfix window: E553: No more items
. I'm able to suppress this with:
silent execute "vimgrep /" . a:search . "/gj **/* | copen"
. However, as soon as I jump to the first match in another file, the error comes up again, cancelling the rest of the substitution.