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

vim: improve autosave events, fix re-sourcing

This commit is contained in:
Joe Groocock 2018-03-30 14:44:32 +01:00
parent 6129bb6794
commit 9a37bbb4c1
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86

View File

@ -32,15 +32,16 @@ set autoread
set showmatch
set scrolloff=6
set nojoinspaces
set updatetime=500 " reduce delay from 4s default
" Autosave settings
function SaveIfExist()
if @% != "" && filereadable(@%)
function! SaveIfExist()
if @% != "" && filereadable(@%) && !&readonly
write
endif
endfunction
set autowrite
autocmd InsertLeave * call SaveIfExist()
autocmd CursorHold,CursorHoldI,InsertLeave,FocusLost * call SaveIfExist()
" Search options
set hlsearch
@ -233,10 +234,10 @@ endif
" Save aliases.
noremap <Leader>q :wq<CR>
com W w
com Q q
com Wq wq
com WQ wq
com! W w
com! Q q
com! Wq wq
com! WQ wq
" Write with sudo
cmap w!! w !sudo tee > /dev/null %