Articles tagged “diff”

Git Diff and Vim

Now that I’ve seen the light and begun using git instead of subversion, I thought I’d post a follow up to my previous post about using vimdiff with subversion. That has by far been the most popular post on this site, so hopefully this will reach and help some of my fellow git users out there.

Setting up git to use vimdiff is virtually the same as with subversion. You need a vimdiff wrapper, and you need to tell git to use that wrapper as the diff program. First, the wrapper, gitvimdiff (anywhere in your path):

exec /usr/bin/vimdiff ${2} ${5}

After that, just need to edit your ~/.gitconfig file:

[diff]
  external = gitvimdiff
[pager]
  diff =

Big thanks to Jonathan Palardy for the info, I’ve just reproduced it here to help spread the word.

Published on July 13, 2009 Comments

· · ·

SVN Diff and Vim

Now that I’m starting to really get used to using svn for all my config files and web dev work, I’ve noticed I use the command svn diff a lot. By default this outputs a unified diff to stdout if any differences are found. While this is good information to have, it’s a really sucky way to display it — especially when we have tools like sdiff and vimdiff at our exposure.

sdiff simply takes the two input files and prints them out side by side with changes noted as characters in between the files. While this is much much better than the standard output of svn diff, vimdiff is still a better alternative because of it’s syntax highlighting.

vimdiff (or vim -d if you so choose) opens up vim in diff mode. This mode by default is two vertical split screens with one file in each screen. As usual, vim does some highlighting magic to make the output pretty and more meaningful. It also has a few commands to make your life easier when merging two versions of the same file (read up on do, dp, :diffget and :diffput).

Anyway, on to the point. To set up svn to use vimdiff as it’s default output you’ve got to do a few things. First, you need to create a wrapper around vimdiff. This is because of the way svn calls the diff utility, as far as I know there is no way around it. My vimdiff wrapper is below.

After that, you need to do one of two things:

OR

Published on December 22, 2008 Comments