I want to check file before quitinq vim
with custom functions, everything seems fine with QuitPre
autocommand except using ZZ
to exit. In this case the output is missing.
Consider following function declaration and autocommand in file function.vim
au QuitPre * call CheckBeforeQuit()
function CheckBeforeQuit()
echo 'Hello'
echo 'World'
call input('Press enter')
endfunction
And now when I open file tmp
with this command
vim tmp -u NONE -c 'source function.vim'
and then type :x
, the output Hello\nWord
along with prompt message is visible. If I use ZZ
instead, the message from echo
is missing. According to help ZZ
is the same as :x
.
Of course I could remap ZZ
to :x
and everything is fine now. But anyway I would like to know what is causing this difference and how I could deal with that in my function.
:x
normal command: github.com/vim/vim/blob/… It will require more investigation because AFAIK it shouldn't remove the messages. – nobe4 Jan 16 '17 at 17:27ZZ
and:x
, but rather it's a difference between how normal and ex-mode commands show output. With ex-mode (command mode), you see the whole output. With normal command, you only see the last line (unless your mapping also enters command mode). – Thunderbeef Oct 9 '19 at 23:14