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?
Edit:
I'm pretty sure that the better way to do what I intended by using BufLeave
-- saving buffers when I switch between them, so I don't get "No write since last change" -- is to set 'autowriteall'
. The question still stands for when MacVim loses focus to other applications (FocusLost
).