4

I use an autocommand to close the preview window when I leave insert mode as described in this answer. But when I am in the command-line window (q:), I get an error: E11: Invalid in the command-line window; <CR> executes, CTRL-C quits: :pclose|endif

How can I prevent this error?

I tried running :set in the command-line window and a regular window, but no obvious option revealed itself in the diff.

Community
  • 1
  • 1
idbrii
  • 10,975
  • 5
  • 66
  • 107

1 Answers1

6

Use silent! to suppress the error:

autocmd CursorMovedI *  if pumvisible() == 0|silent! pclose|endif
autocmd InsertLeave * if pumvisible() == 0|silent! pclose|endif
perreal
  • 94,503
  • 21
  • 155
  • 181