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

However in KDiff3 I can toggle to show whitespace changes, allowing me to focus just on the actual code that changed

Whitespace on
image

Whitespace off
image

 

Step 1: Install your diff tool of choice

Below are some I have previously used

 

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

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

image
image

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 (for Word files)

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

Translating emails easily in Outlook

I have been working with SSW’s Beijing office for over 12 months now. One common occurrence is that I am CC’d on emails to our Chinese customers, but unfortunately I can’t read Chinese. It is very useful for me to quickly read these emails so I have an idea of what correspondence is going on.

The easiest way I have found to keep myself in the loop and check in on threads periodically is by adding a button to the Outlook ribbon bar to quickly translate the current document for me. Here is an example of how to set it up and translate an email.

Step 1: Customise the ribbon
image

Step 2: Select the Home tab and create a new group. Call it Translation, then add “Translate Document”. Press OK to save it
image

Step 3: You will now see the translate button in the ribbon, press it to set up what language it should translate from and to.
image

It will then warn you that your email will be sent over the internet to the translation service
image

 

That is it. Now in your ribbon bar you will see your button ready to use.
image

Clicking it will open up a browser with your document translated
image