Disclaimer: This question may be specific to Gvim on a Windows machine.
So far, FocusLost
would be recognized when the "focus" gets switched from the gvim.exe
process to any other process of different names. However, FocusLost
will do nothing when I change from one gvim.exe
process to the other. (In Windows OS, each gvim.exe
process correspond to a "window".)
A working example of mine was introduced in this post: How to exit insert mode using autocommand upon losing focus?, where the refined command that saves the document + exit insert mode goes as follows:
autocmd FocusLost * stopinsert | wall!
The goal is to eventually enable auto-save when one leaves the active GVim window.