I had problem with YCMD server not shutting down properly, so I tried to kill it on VimLeave. After a couple tries I detected that VimLeave/VimLeavePre event not firing on vim exit. VimEnter is working though. What could be the cause of this?

  • How did you determine VimLeave and VimLeavePre are not triggered? – Sato Katsura Jul 20 '16 at 15:21
  • @SatoKatsura autocmd VimLeave * :!touch ~/hiVimLeave - nothing and autocmd VimEnter * :!touch ~/hiVimEnter - file created – fourslashw Jul 20 '16 at 15:25
  • 2
    Not a good test, since you no longer have any buffer. Try something like this instead: autocmd VimLeave * call writefile([v:dying], '/tmp/some_file', 'a'). Don't expect writefile() to resolve ~ and the like. – Sato Katsura Jul 20 '16 at 15:30
  • 1
    You might want to complain to Debian maintainers of Vim then. It works fine with recent versions of Vim. – Sato Katsura Jul 20 '16 at 15:42
  • 1
    You might already have a VimLeave auto command defined somewhere, which will take precedence; futher ones won't be executed. :au vimleave to see what's already defined. Try au! vimleave before defining your autocommand to delete any existing ones. – Antony Jul 20 '16 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.