Insert the following block of code in .vim/plugin/gitdiff.vim. When you want
to see the diff of the edited file and the one on the server, run the command
:GITDiff inside from vim.
1234567891011121314151617181920212223242526272829
if exists("loaded_gitdiff")|| &compatiblefinishendiflet loaded_gitdiff =1command!-nargs=? GITDiff :calls:GitDiff(<f-args>)function!s:GitDiff(...)ifa:0==1let rev =a:1elselet rev ='HEAD'endiflet ftype = &filetypelet prefix = system("git rev-parse --show-prefix")let gitfile = substitute(prefix,'\n$','','') . expand("%") " Check out the revision to a temp filelet tmpfile = tempname()let cmd ="git show " . rev . ":" . gitfile . " > " . tmpfile
let cmd_output = system(cmd)ifv:shell_error && cmd_output !="" echohl WarningMsg |echon cmd_output
returnendif " Begin diff exe "vert diffsplit" . tmpfile
exe "set filetype=" . ftype
setfoldmethod=diffwincmdlendfunction