How can I make Vim autosave files when it loses focus?

前端 未结 4 718
梦谈多话
梦谈多话 2020-12-25 11:02

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 Bu         


        
4条回答
  •  南笙
    南笙 (楼主)
    2020-12-25 11:48

    You don’t care about errors in those circumstances since there is nothing you can reasonably do about them anyway – especially when losing focus. So just swallow them:

    autocmd BufLeave,FocusLost * silent! wall
    

    Much simpler than an elaborate dance to figure out where there would be an error in order to avoid it.

提交回复
热议问题