Dev Tip: Customising Visual Studio to use a different merge tool
One tip I picked up after many years of using Visual Studio and TFS is that the default diffing tool in Visual Studio is… lacking. But the great thing is that you can customise Visual Studio to use a different diff and merge tool.
My tool of choice is KDiff 3 (Package also available on Chocolatey.org) as it is free and open source. Meaning I am able to just install it via Chocolatey on all my machines without a second thought.
Here is a great example of why you may want to change your default diff tool. Below is a web.config file that was reformatted by a tool and simply put an additional space before the closing tag. Visual Studio flags every single line as having changed, but I can’t find the actual lines that were changed by me.
However in KDiff3 I can toggle to show whitespace changes, allowing me to focus just on the actual code that changed
Step 1: Install your diff tool of choice
Below are some I have previously used
- Kdiff 3 (My Recommendation)
- Website - http://kdiff3.sourceforge.net/
- Chocolatey - https://chocolatey.org/packages/kdiff3
- WinMerge
- Website - http://winmerge.org/
- Chocolatey - https://chocolatey.org/packages/winmerge
- Beyond Compare
- Website - http://www.scootersoftware.com/
- Chocolatey - https://chocolatey.org/packages/beyondcompare
Step 2: Open the Visual Studio Options
From Visual Studio select Tools –> Options. Then navigate to Source Control –> Visual Studio Team Foundation.
Then click Configure User Tools.
Step 3: Enter the command line parameters
In the configure use tools screen. Click Add.
- For the extension enter .*
- Command select the diff tool .exe
- Enter the arguments from the table below based on if you are defining the compare or merge
The table below is duplicated from a 2006 blog post. I’d hate for the content to ever disappear off the web. All credits go to the James Manning’s original post.
Compare arguments
Product | Command | Arguments |
TFS default | diffmerge.exe | %1 %2 %6 %7 %5 /ignorespace |
WinDiff | windiff.exe |
%1 %2 |
DiffDoc.exe | /M%1 /S%2 | |
WinMerge | winmerge.exe | /ub /dl %6 /dr %7 %1 %2 |
Beyond Compare | bc2.exe | %1 %2 /title1=%6 /title2=%7 |
KDiff3 | kdiff3.exe | %1 --fname %6 %2 --fname %7 |
Araxis | compare.exe | /wait /2 /title1:%6 /title2:%7 %1 %2 |
Compare It! | Wincmp3.exe | %1 /=%6 %2 /=%7 |
SourceGear DiffMerge | DiffMerge.exe | /title1=%6 /title2=%7 %1 %2 |
Beyond Compare 3 | BComp.exe | %1 %2 /title1=%6 /title2=%7 |
TortoiseMerge | TortoiseMerge.exe | /base:%1 /mine:%2 /basename:%6 /minename:%7 |
Visual SlickEdit | win\vsdiff.exe | %1 %2 |
Merge arguments
Product | Command | Arguments |
TFS default | diffmerge.exe | /merge %1 %2 %3 %4 %6 %7 |
KDiff3 | kdiff3.exe | %3 --fname %8 %2 --fname %7 %1 --fname %6 -o %4 |
Visual SourceSafe | ssexp.exe | /merge %1 %2 %3 %4 %6 %7 |
Araxis | compare.exe | /wait /swap /a3 /3 /title1:%6 /title2:%7 /title3:%8 %1 %2 %3 %4 |
Beyond Compare (2-way merge) | bc2.exe | %1 %2 /savetarget=%4 /title1=%6 /title2=%7 |
WinMerge (2-way merge) | winmerge.exe | /ub /dl %6 /dr %7 %1 %2 %4 |
Guiffy | guiffy.exe | -s -h1%6 -h2%7 -hm%9 %1 %2 %3 %4 |
Ellie Computing | guimerge.exe | --mode=merge3 %3 %1 %2 --to=%4 --title0=%8 --title1=%6 --title2=%7 --to-title=%9 |
SourceGear DiffMerge | DiffMerge.exe | /title1=%6 /title2=%8 /title3=%7 /result=%4 %1 %3 %2 |
Beyond Compare 3 | BComp.exe | %1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9 |
TortoiseMerge | TortoiseMerge.exe | /base:%3 /mine:%2 /theirs:%1 /basename:%8 /minename:%7 /theirsname:%6 /merged:%4 /mergedname:%9 |
Visual SlickEdit | win\vsmerge.exe | %3 %1 %2 %4 |