1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

vim: autosave modified files, also when FocusGained

This commit is contained in:
Joe Groocock 2018-03-31 21:52:28 +01:00
parent 7bbe3f07c0
commit 94b221ebb3
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86

View File

@ -42,12 +42,12 @@ let mapleader="\<space>"
" Autosave settings
function! SaveIfExist()
if @% != "" && filereadable(@%) && !&readonly
if @% != "" && filereadable(@%) && !&readonly && &modified
write
endif
endfunction
set autowrite
autocmd CursorHold,CursorHoldI,InsertLeave,FocusLost * call SaveIfExist()
autocmd CursorHold,CursorHoldI,InsertLeave,FocusGained,FocusLost * call SaveIfExist()
" Search options
set hlsearch