" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" Find diff inbetween currrent buffer and ... A{last index version} vs B{last saved version in working directory}
" - A{last index version}: the file as you last commited it
" git diff to vimdiff against the index version of the file:
nnoremap <leader>gd <Esc>:Gvdiff<CR><Esc>:echo "currentBuffer vs lastIndexVersion (last commited)"<CR>
" - B{last saved version in working directory}: the file you last :w,
" not neccesary commited it (not commited for sure if it is in NO git project)
" https://vim.fandom.com/wiki/Diff_current_buffer_and_the_original_file
nnoremap <leader>gd2 <Esc>:DiffSaved<CR><Esc>:echo "currentBuffer vs lastSaved (not neccesary equal to last commited)"<CR>
function! s:DiffWithSaved()
let filetype=&ft
diffthis
vnew | r # | normal! 1Gdd
diffthis
exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
endfunction
com! DiffSaved call s:DiffWithSaved()