0

I would like to create a vim command that is waiting for an input THEN that will execute ':cw' automatically after the first command.

Here is what I try:

noremap <C-p> :exec ":ProjectGrep /".input('Search: ')"/ src/**"<CR>:cw

But the ':cw' does not execute after the command, it complete the input().

Schminitz
  • 314
  • 1
  • 2
  • 13

1 Answers1

3

Add the following snippet to your vimrc to make Vim open the quickfix/location window when there are valid errors/locations:

augroup qf
    autocmd!
    autocmd QuickFixCmdPost [^l]* cwindow
    autocmd QuickFixCmdPost l* lwindow
augroup END

That snippet addresses what I believe is your underlying issue (having the quickfix window open automatically after your search command), though, not your actual question.

Anyway, cwindow should be the last command in the function called by your :ProjectGrep command; not at the mapping level.

romainl
  • 186,200
  • 21
  • 280
  • 313