Improved unsaved command
This commit is contained in:
parent
d88106da00
commit
3e28a6b265
1 changed files with 16 additions and 25 deletions
31
vimrc
31
vimrc
|
@ -289,36 +289,27 @@ function! s:hex(...)
|
||||||
endfunction
|
endfunction
|
||||||
command! -nargs=* Hex call <sid>hex(<q-args>)
|
command! -nargs=* Hex call <sid>hex(<q-args>)
|
||||||
|
|
||||||
function! s:unsaved_new()
|
function! s:unsaved()
|
||||||
let tmp_file = expand("%:p").".tmp"
|
if &mod
|
||||||
exec "w ".tmp_file
|
let l:filetype = &filetype
|
||||||
exec "!gvim -d -R % ".tmp_file
|
|
||||||
call delete(tmp_file)
|
|
||||||
endfun
|
|
||||||
|
|
||||||
function! s:unsaved_same()
|
|
||||||
diffthis
|
diffthis
|
||||||
below new
|
below new
|
||||||
set buftype=nofile
|
set modifiable
|
||||||
r #
|
r #
|
||||||
diffthis
|
diffthis
|
||||||
au BufUnload <buffer> diffoff!
|
au BufUnload <buffer> diffoff!
|
||||||
|
let &filetype = l:filetype
|
||||||
|
set nomodifiable
|
||||||
|
set buftype=nofile
|
||||||
|
set bufhidden=delete
|
||||||
|
silent exec "file =".expand("#:t")."@".strftime("%H:%M")
|
||||||
exec "normal \<C-w>k"
|
exec "normal \<C-w>k"
|
||||||
endfun
|
set foldlevel=999
|
||||||
|
|
||||||
function! s:unsaved(...)
|
|
||||||
if &mod
|
|
||||||
if a:0
|
|
||||||
call <sid>unsaved_new()
|
|
||||||
else
|
|
||||||
call <sid>unsaved_same()
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
echom "No changes to show :)"
|
echom "No changes to show :)"
|
||||||
end
|
end
|
||||||
endfun
|
endfun
|
||||||
|
command! Unsaved call <sid>unsaved()
|
||||||
command! -nargs=? Unsaved call <sid>unsaved(<args>)
|
|
||||||
|
|
||||||
" === GENERAL KEY MAPPINGS ===
|
" === GENERAL KEY MAPPINGS ===
|
||||||
let mapleader = "\\"
|
let mapleader = "\\"
|
||||||
|
|
Loading…
Reference in a new issue