gitvimdiff

Can vim diff use the patience algorithm?


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:


Solution

  • 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.