Improved autosave + added save prompt
- Auto-save now triggers when nothing is typed for a while - Pressing C+s now asks the user to type "save"
This commit is contained in:
parent
50e9538394
commit
e016daaf29
1 changed files with 27 additions and 7 deletions
34
vimrc
34
vimrc
|
@ -378,8 +378,14 @@ noremap <C-space> @:
|
||||||
noremap Q @q
|
noremap Q @q
|
||||||
nnoremap <S-space> gQ
|
nnoremap <S-space> gQ
|
||||||
" noremap <C-s> :w<CR>
|
" noremap <C-s> :w<CR>
|
||||||
noremap <C-s> :echo "Calm the fuck down! There's
|
function! s:saveprompt()
|
||||||
\ no need to save every 10 seconds FFS!"<CR>
|
if input("Type 'save' to save: ") ==? "save"
|
||||||
|
write
|
||||||
|
else
|
||||||
|
echo "Calm the fuck down man!"
|
||||||
|
end
|
||||||
|
endfun
|
||||||
|
noremap <C-s> :call <sid>saveprompt()<CR>
|
||||||
nnoremap <C-n> :bnext<CR>
|
nnoremap <C-n> :bnext<CR>
|
||||||
nnoremap <C-p> :bprevious<CR>
|
nnoremap <C-p> :bprevious<CR>
|
||||||
nnoremap <leader>j :lnext<cr>
|
nnoremap <leader>j :lnext<cr>
|
||||||
|
@ -481,15 +487,29 @@ function! s:toggleWUC()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Autosave when vim loses focus :)
|
" Autosave when vim loses focus :)
|
||||||
function! TryAutosave()
|
function! TryAutosave(warn, single)
|
||||||
if &autowriteall==1
|
if &autowriteall==1
|
||||||
silent w
|
if a:single
|
||||||
|
if &mod
|
||||||
|
silent write
|
||||||
|
if a:warn
|
||||||
|
echo "Autosaving current buffer..."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
silent wall
|
||||||
|
if a:warn
|
||||||
|
echo "Autosaving all buffers..."
|
||||||
|
end
|
||||||
|
end
|
||||||
redraw
|
redraw
|
||||||
echo "Autosaving buffers..."
|
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
au FocusLost * call TryAutosave()
|
augroup autosave
|
||||||
" au WinLeave * call TryAutosave()
|
autocmd!
|
||||||
|
autocmd FocusLost * call TryAutosave(0, 0)
|
||||||
|
autocmd CursorHold * call TryAutosave(0, 1)
|
||||||
|
augroup END
|
||||||
|
|
||||||
vnoremap <leader>g :<C-u>call <SID>GrepOperator(visualmode())<CR>
|
vnoremap <leader>g :<C-u>call <SID>GrepOperator(visualmode())<CR>
|
||||||
nnoremap <leader>g :set operatorfunc=<SID>GrepOperator<CR>g@
|
nnoremap <leader>g :set operatorfunc=<SID>GrepOperator<CR>g@
|
||||||
|
|
Loading…
Reference in a new issue