Reputation: 2099
I have an au command to check if a file had been changed:
autocmd CursorHold * checktime
But when I launch a command line window with q:
or with q/
than I get the following error:
Error detected while processing CursorHold Auto commands for "*":
E11: Invalid in command-line window; <CR> executes, CTRL-C quits: checktime
Press ENTER or type command to continue
My question is, is it possible to set up the autocmd's pattern to exclude command line buffers and other readonly buffers?
Upvotes: 1
Views: 827
Reputation: 172688
The easiest fix is to just silence the errors:
autocmd CursorHold * silent! checktime
Alternatively, you could also wrap this in try
...catch /:E11:/
. Or, you could attempt to check for the command-line window:
autocmd CursorHold * if expand('%') !=# '[Command Line]' | checktime | endif
Upvotes: 4