I'm trying to create a command that would accept arguments, and then call vimgrep
with those arguments and display the quickfix window. I set up my command like
command! -nargs=* Vsearch :call <SID>VimGrepSeach(<q-args>)
and my <SID>VimGrepSearch
is defined by:
function <SID>VimGrepSearch(query)
execute "normal! q:vimgrep /\\v" . a:query . '\g' escape('**/*', ' \')
endfunction
This will search all of the current directory and display the results in a quickfix window, if the equivalent is ran directly from command mode.
However, when I run this as a command, I get the quickfix quickly popping up, but then it's immediately hidden. What's going on here? Why does the quickfix window appear and then hide, and how can I have it stay open?
q:
? That opens the command window. Try justexecute "vimgrep /\\v" ...
and thencopen
on the line below. – D. Ben Knoble♦ Jan 26 '20 at 6:18**/*
. – SalmonKiller Jan 26 '20 at 6:30normal! q:
... that shouldnt give you any new errors – D. Ben Knoble♦ Jan 26 '20 at 14:33\g
should be/g
– D. Ben Knoble♦ Jan 26 '20 at 14:39execute 'vimgrep /\v' . a:query . '/g **/*'
followed bycopen
. @D.BenKnoble, you got all of those, you should turn them into an answer. – filbranden♦ Jan 26 '20 at 16:36