How can I make Vim autosave files when it loses focus?
- by Peeja
I'm used to my editors autosaving files when they lose focus. I recently switched to MacVim, and I can't recreate that behavior. I tried this:
autocmd BufLeave,FocusLost * wall
but if a buffer is unnamed when the window or MacVim loses focus, I get an error like the following:
Error detected while processing BufLeave Auto commands for "*":
E141: No file name for buffer 1
I'm confused, because :wall's documentation says:
Write all changed buffers. Buffers without a file
name or which are readonly are not written.
so I'd expect it to skip unnamed buffers. Is there a better way to do this?