To set up vim as your diff tool in Visual Studio choose Tools > Options from the menu and select the Source Control > Visual Studio Team Foundation Server node in the tree on the left (these instructions are TFS specific), giving you this view:
Click the Configure User Tools button and then click Add, giving you this box:
Fill in the values as shown (obviously the Command path may be different on your machine), and hit OK. Use the OK buttons to close the remaining two dialogs.
The file extension can be used to determine what kinds of files are diffed in this way, the command is the program used.
The argument string is as follows:
- -d puts vim into diff mode (kinda important)
- -R puts vim into readonly mode (making comparisons safer)
- %1 and %2 are the names of the files to be compared, the arrow to the right of
this box gives a full list of those available
Additionally I have added this clause to my .vimrc file:
if &diff set columns=240 endif
My .vimrc file specifies 120 columns so doubling this for side-by-side diffing results in a consistent experience.
Setting up for merging is identical except you choose Merge from the operation dropdown and you additionally specify %4 for the merged file name in the argument list (I put this last). Rather obviously, you do not specify -R for merge operations as you need to edit the resulting file.