tags:

views:

167

answers:

1

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
Or you might want wall! if you're editing readonly files
Benj
I think this can only work in gvim? Because if you run vim in a terminal, it knows nothing about windows or focus.
intgr
Yes this is true, vim has no access windowing functions such as focus etc...
Benj
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
Thx for your answer. It's working for gvim but not for vim in a linux shell.
1passenger
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