Is there any way to set vimdiff's diff strategy to be the patience algorithm? It's built into git and seems to be much better than a normal diff.
For reference:
Is there any way to set vimdiff's diff strategy to be the patience algorithm? It's built into git and seems to be much better than a normal diff.
For reference:
As of vim 8.1.0360 (Sep 2018), vim (except as packaged by Apple 😠) ships with xdiff (the same library that git uses for diffs), meaning patience diff is now natively supported in vim and neovim (see neovim issue 1466). Add this to your vimrc:
if has("mac") && $VIM == "/usr/share/vim" set diffopt-=internal elseif has("patch-8.1.0360") set diffopt+=internal,algorithm:patience endif A nice introduction to both the new algorithm:patience and indent-heuristic (added in the same release) diff options can be found at Vimways ~ The power of diff.
indent-heuristic flag.indent-heuristic is not directly related to the patience algorithm and therefore isn't in my example settings for the patience algorithm. It is, however, in my .vimrc 😉vim on macOS does not support xdiff despite having the patch.see :help diff-diffexpr: http://vimdoc.sourceforge.net/htmldoc/diff.html#diff-diffexpr
you might be able to set it to something like
set diffexpr=MyDiff() function MyDiff() let opt = "" if &diffopt =~ "iwhite" let opt = opt . "-w " endif silent execute "!git diff --no-index --patience " . opt . v:fname_in . " " . v:fname_new . " > " . v:fname_out endfunction I tried this, but I did not get it to work as git outputs unified diff format, while vim expects ed style format (see doc above). You might have to transform the output of git diff, which is probably not what you want.