Browse Source

Add auto save

pull/4/head
Ein Verne 6 years ago
parent
commit
423a65bf13
No known key found for this signature in database
GPG Key ID: F80B65F734D9DD7D
  1. 22
      .vimrc

22
.vimrc

@ -243,11 +243,29 @@ set t_Co=256
" let g:Powerline_symbols='fancy'
" autosave when lost focus
:au FocusLost * silent! wa
:au FocusLost * :wa
au FocusLost * silent! wa
au FocusLost * :wa
autocmd TextChanged,TextChangedI <buffer> silent write
autocmd CursorHold, CursorHoldI * update
" save on buffer switch
set autowrite
set autowriteall
let g:autosave_time_period = 10
au BUfRead,BufNewFile * let b:start_time=localtime()
" only write if needed and update the start time after save
function! UpdateFile()
if ((localtime() - b:start_time) >= g:autosave_time_period)
update
echo "Time: " . (localtime() - b:start_time) . " seconds have elapsed. File saved."
let b:start_time=localtime()
endif
endfunction
au CursorHold * call UpdateFile()
" general mapping
" no <up> ddkP
" no <down> ddp

Loading…
Cancel
Save