Improved unsaved command

This commit is contained in:
Talia 2018-01-30 19:12:00 +01:00
parent d88106da00
commit 3e28a6b265

41
vimrc
View file

@ -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"
exec "w ".tmp_file
exec "!gvim -d -R % ".tmp_file
call delete(tmp_file)
endfun
function! s:unsaved_same()
diffthis
below new
set buftype=nofile
r #
diffthis
au BufUnload <buffer> diffoff!
exec "normal \<C-w>k"
endfun
function! s:unsaved(...)
if &mod if &mod
if a:0 let l:filetype = &filetype
call <sid>unsaved_new() diffthis
else below new
call <sid>unsaved_same() set modifiable
end r #
diffthis
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"
set foldlevel=999
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 = "\\"