How can I configure vim to autowrite buffers after switching with alt-tab to another application?
+7
A:
You want:
autocmd FocusLost * :wall
In your .vimrc
I just tried it and it seems to work.
Benj
2009-11-16 13:55:53
Or you might want wall! if you're editing readonly files
Benj
2009-11-16 13:56:28
I think this can only work in gvim? Because if you run vim in a terminal, it knows nothing about windows or focus.
intgr
2009-11-16 13:56:50
Yes this is true, vim has no access windowing functions such as focus etc...
Benj
2009-11-16 13:58:37
Actually the vim doc says: "Only for the GUI and a few console versions were this can be detected" although I've got no idea what those would be....
Benj
2009-11-16 13:59:48
Thx for your answer. It's working for gvim but not for vim in a linux shell.
1passenger
2009-11-16 14:02:46
Hi 1passenger, I'm pretty sure this would be impossible for vim in a linux shell for the reasons above. (Unless you wrote some kind of C code to interface to xwindows that is but I wouldn't recommend it)
Benj
2009-11-16 14:13:58