How to autosave in Vim 7 when focus is lost from the window?

I tried the following in my .vimrc:

:au FocusLost * silent! wa
autocmd BufLeave,FocusLost silent! wall

And also tried:

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

but cannot make it work when I do Ctrl + Z or switch to another tab in the terminal (Mac), it still doesn't save automatically.

+5
source share
2 answers

BufLeaveIt starts when changing to another buffer. Neither <C-z>switching to another Terminal.app tab will cause this, because you are using the CLI Vim, which does not care about the GUI of the terminal emulator or the environment and ... you do not leave your buffer.

FocusLost ( , , GUI, , , ).

, , , MacVim, CLI Vim.

, Vim , , , CLI Vim.

~/.vimrc autocmd FocusLost * :wa, if has("gui_running") , inoremap <Esc> <Esc>:w<CR>, ESC. , .

+11

OS X Vim CLI http://www.vim.org/scripts/script.php?script_id=4521

AutoSave - :w( ) , . , :AutoSaveToggle, / . , , g:auto_save ( 'let g:auto_save = 1' .vimrc).

+1

All Articles