by Joakim

Using WinMerge as the default diff/merge tool in Visual Studio 2012/2013

Updated: The procedure described below also works for Visual Studio 2013!

I found the default diff/merge tool in Visual Studio 2012 to be a huge improvement over previous versions, as now you are actually able to see what has changed quite easily.

vs12-compare-1

But that being said, I still prefer to use WinMerge as the default diff/merge tool since it has more features. Another nice feature of WinMerge is the possibility to integrate it into Windows Explorer which allows me to diff files (and folders) on my hard drive.

So how do you make WinMerge the default diff/merge tool in Visual Studio?

Go into “Tools –> Options –> Source Control –> Visual Studio Team Foundation Server”, click on “Configure User Tools …”, and add new commands for the “Compare” and “Merge” operations.

vs12-compare-3

vs12-compare-4

Values for the compare command;
Extension: .* (meaning all files)
Operation: Compare
Command: C:Program Files (x86)WinMergeWinMergeU.exe (the path to where WinMergeU.exe is located)
Arguments: /e /u /wl /dl %6 /dr %7 %1 %2 (the arguments for WinMerge, I’ll explain them in detail further down)

Values for the merge command;
Extension: .*
Operation: Merge
Command: C:Program Files (x86)WinMergeWinMergeU.exe
Arguments: /e /u /wl /dl %6 /dr %7 %1 %2 %4

After you add these two commands, right-clicking a file in Visual Studio and selecting “Compare…” should result in the two files being opened and compared in WinMerge. Should you want to go back to using Visual Studio’s own diff/merge tool, you just remove the two commands again.

vs12-compare-2

So what do the values used in the arguments field in the two commands actually mean?

Values starting with a forward slash (/) are WinMerge command-line parameters. The full list of possible parameters can be found here. But I’ll list the ones I use (not all of them are necessary, you may remove some or add others as you prefer):

/e –> Enables you to close WinMerge with a single Esc key press
/u –> Prevents WinMerge from adding either path (left or right) to the Most Recently Used (MRU) list
/wl –> Opens the left side as read-only
/dl –> Specifies a description in the left side title bar
/dr –> Specifies a description in the right side title bar

Values starting with a percentage sign (%) are provided by Visual Studio as input for the WinMerge parameters. You can see what they stand for by clicking the “play” button behind the arguments field when you create the command, but I’ll list them here as well (I’ve greyed out those I don’t use):

%1 –> Original file
%2 –> Modified file
%3 –> Base file
%4 –> Merged file
%5 –> Diff command-line options
%6 –> Original file label
%7 –> Modified file label
%8 –> Base file label
%9 –> Merged file label

WinMerge can be downloaded the from here.

  • VG

    Very helpful.
    Thanks a lot.

  • http://www.achadwick.com Allan Chadwick

    I’m getting an error of “Parameter count mismatch.” in a windows os popup when I right click on the test config (in my case:Web.Test.config) and select Preview Transform. This works with the default diff merge, but breaks on Winmerge. Any Ideas??

  • http://www.degree.no Joakim

    @Allan: No sorry, I’ve not had any problems using WinMerge as the diff/merge tool in VS. Are you sure you have the correct switches/parameters for the compare and merge commands respectively? (As you can see merge has an extra input parameter -> %4)

  • romb

    Very helpful, saved lots time for me, thanks a lot, man

  • LK

    I had to remove the %4 argument to get this to work in VS2015 enterprise.