Extremely related to this except the answer there doesn't work
I get the following error when entering command-line editing mode q:
or Ctrl-F
(when already in command mode)
Error detected while processing CursorHold Auto commands for "*":
E11: Invalid in command-line window; <CR> executes, CTRL-C quits: checktime | endif
The relevant section of my .vimrc is
"automatically reload file when changes detected
set autoread "this doesn't work on it's own!
"https://unix.stackexchange.com/questions/149209/refresh-changed-content-of-file-opened-in-vim/383044#383044
"on these events, any filename... and not in command mode then check files for changes
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif
" Notification after file change
autocmd FileChangedShellPost *
\ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None
So my question is how do I detect that I'm in the command-line window and stop that command from running there?
After a bit of reading :h command-line
I tried replacing the condition with
if mode() != 'c' && getcmdwintype() == ''
but I'm still seeing the same issue.
~/test.vimrc
), start vim withvim -u ~/test.vimrc
and confirm that you still get the error. If you don't get the error maybe the problem comes from another autocmd.VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct 20 2017 11:15:05) Included patches: 1-1207 Modified by [email protected] Compiled by [email protected]
it seems a little surprising that the other answer clearly worked for someone else but isn't for me - could be a version thing maybeCursorHold
event which would cause a problem?