Fixed + improved autosave stuff
This commit is contained in:
parent
05579eaa8c
commit
05c6716944
1 changed files with 16 additions and 15 deletions
25
vimrc
25
vimrc
|
@ -376,11 +376,14 @@ nmap <C-k> :exec "normal ".g:jmp_dist."k"<CR>
|
||||||
" Yes, not 'noremap', do whatever is mapped to J and K assuming
|
" Yes, not 'noremap', do whatever is mapped to J and K assuming
|
||||||
" it is some sort of custom up-down motion, but g:jmp_dist times
|
" it is some sort of custom up-down motion, but g:jmp_dist times
|
||||||
|
|
||||||
|
" --- modes ---
|
||||||
|
nnoremap <ins> <ins><ins>
|
||||||
|
|
||||||
" --- /dev/null ---
|
" --- /dev/null ---
|
||||||
noremap <leader>d "_d
|
noremap <leader>d "_d
|
||||||
noremap <leader>d "_d
|
noremap <leader>d "_d
|
||||||
noremap x "_x
|
noremap <del> "_x
|
||||||
noremap <leader>x x
|
noremap <S-del> 0"_x$
|
||||||
|
|
||||||
" --- Numbers ---
|
" --- Numbers ---
|
||||||
nnoremap <leader>- <C-x>
|
nnoremap <leader>- <C-x>
|
||||||
|
@ -534,18 +537,15 @@ endfunction
|
||||||
|
|
||||||
" Autosave when vim loses focus :)
|
" Autosave when vim loses focus :)
|
||||||
function! TryAutosave(warn, mode)
|
function! TryAutosave(warn, mode)
|
||||||
if &autowriteall==0 " All buffers
|
|
||||||
if a:mode == 0
|
if a:mode == 0
|
||||||
|
if &autowriteall || &autowrite
|
||||||
silent wall
|
silent wall
|
||||||
if a:warn
|
if a:warn
|
||||||
echo "Autosaving all buffers..."
|
echo "Autosaving all buffers..."
|
||||||
end
|
end
|
||||||
elseif a:mode == 1
|
|
||||||
silent wall " Lie to the user and save everything :)
|
|
||||||
if a:warn
|
|
||||||
echo "Autosaving all buffers in tab..."
|
|
||||||
end
|
end
|
||||||
elseif a:mode == 2
|
elseif a:mode == 1
|
||||||
|
if &autowriteall
|
||||||
if &mod
|
if &mod
|
||||||
silent write
|
silent write
|
||||||
if a:warn
|
if a:warn
|
||||||
|
@ -553,15 +553,16 @@ function! TryAutosave(warn, mode)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
redraw
|
redraw
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
augroup autosave
|
augroup autosave
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd FocusLost * call TryAutosave(0, 0)
|
autocmd FocusLost * call TryAutosave(0, 0)
|
||||||
autocmd TabLeave * call TryAutosave(0, 1)
|
autocmd BufLeave * call TryAutosave(0, 1)
|
||||||
autocmd BufLeave * call TryAutosave(0, 2)
|
autocmd CursorHold * call TryAutosave(0, 1)
|
||||||
autocmd CursorHold * call TryAutosave(0, 2)
|
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
vnoremap <leader>g :<C-u>call <SID>GrepOperator(visualmode())<CR>
|
vnoremap <leader>g :<C-u>call <SID>GrepOperator(visualmode())<CR>
|
||||||
|
|
Loading…
Reference in a new issue