Search code examples
vimvimdiff

`vimdiff` not compatible with autocmd?


I was used to use vimdiff and loading the compared files.

Now, on vimdiff execution, it happens:

"a" [readonly] 5454L, 269796C
"b" [readonly] 241L, 10170C
Press ENTER or type command to continue

The only configuration change is the introduction of these two autocmd instructions:

autocmd BufNewFile * call s:Function()
autocmd BufReadPre * call s:Function()

Can this be a normal behavior? Can it be a mistake of mine? Can be something depending on Vim versioning? Can the desired configuration change be combined with a straightforward vimdiff load (no ENTER key needed to continue)?


Solution

  • The dreaded hit-enter prompt is usually triggered by additional :echo[msg] commands, here inside your s:Function(). Either remove them, or silence the output via :silent:

    autocmd BufNewFile * silent call s:Function()