I would:
- Save the current version to disk
- Select the version from the undo tree
- Run the
:Diff
command
Remark: The :Diff
command is not a standard Vim command but it is a common addition.
Here is the version of @romainl:
function! Diff(spec)
vertical new
setlocal bufhidden=wipe buftype=nofile nobuflisted noswapfile
let cmd = "++edit #"
if len(a:spec)
let cmd = "!git -C " .. shellescape(fnamemodify(finddir('.git', '.;'), ':p:h:h')) .. " show " .. a:spec .. ":#"
endif
execute "read " .. cmd
silent 0d_
diffthis
wincmd p
diffthis
endfunction
command! -nargs=? Diff call Diff(<q-args>)