1

In my ~/.vimrc I have at the moment:

autocmd BufLeave,FocusLost * nested silent! wall

Which most of the time works as I would like, however sometimes it seems saving simply stops working (for a particular gvim window, all tabs): when I alt-tab away from the window changes aren't saved. It does seem as though changing to a different tab saves the changes to the buffer, so perhaps FocusLost in particular is not firing?

The only way to get it working again is to close gvim and re-open my files.

I'm not sure how to go about starting to debug this.

EDIT: I've noticed that if I do a :autocmd FocusLost * echo "lost focus" in a broken gvim session nothing is printed when I alt-tab away, while the message is printed as expected in windows where my autosaving is working as expected.

  • Define « not working » – D. Ben Knoble Jun 30 at 23:56
  • 2
    According to :h :wall Write all changed buffers. Buffers without a file name cause an error message. so since you use silent! is it possible that the problem occurs when you open a buffer without a file name and don't see the relevant error because of silent? If so what I would try would be to use :h :bufdo to apply silent w on all buffers, this way if one fails because it can't be saved the other should still get saved. – statox Jul 1 at 7:24
  • @statox Thanks. I've got a window open that's exhibiting this behavior now. I did a :bw <n> for a few buffers that didn't exist (tmp files I'm not sure where they came from), but it didn't change the behavior. – jberryman Jul 5 at 16:19

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.