This is an enhanced version of the snippet provided under :help diff-original-file
.
Where the original :DiffOrig
only shows differences between the buffer in memory and the file on disk, :Diff
can be used in two ways:
-
against the file on disk, like the original, with:
:Diff
-
against an arbitrary Git revision of the current file, with:
:Diff HEAD
This is quite an old gist but I guess some people may still use it. So it's probably worth noting that
finddir()
trick is not needed. Instead, we can forcegit
to figure path itself:-C
option makesgit
to change its working directory first; then it's okay to use "single dot" as relative path inside any commit too.