3

I find myself wanting to use vimgrep without having an open vim session. Then, I usually open a blank vim session (by calling vim from the terminal) and then, for instance, :vim /pattern/ *.tex.

I was wondering whether there is a direct way to call vimgrep from the terminal and end up with an open vim session and a populated quickfix list.

2

It concerns more shell than an editor. I guess, adding this to shell's profile should work

vimgrep() { $EDITOR "+vimgrep $1 $2" "+copen"; }

To call from terminal do not forget to put single quotation marks:

vimgrep '/pattern/' '*.tex'
  • 1
    $EDITOR might be anything, not even vim related. It should probably only be called with vim or nvim. – Christian Brabandt Nov 25 '19 at 12:43
  • @ChristianBrabandt Anyone who asks a question on this site while setting $EDITOR to smth. else should be persecuted ;-) Seriously, any other suggestion would be even less portable. – Matt Nov 25 '19 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.