Tuesday, February 24, 2009

Ignore Whitespace When Comparing in VS2008

Normally when you compare two different versions of an object, a compare tool would show up and highlight the differences between the two versions.  Unfortunately, it does not ignore the whitespace by default.  It could be the difference in the indentation or an extra space somewhere.  One such compare shows me that just about everything is different in the two versions but really it is just showing the extra space that was at the end of each line to be different.

Well, I found a little trick so that Whitespace is ignored when comparing two different versions of an object in TFS.

  1. In Visual Studio 2008;  Go to Tools –> Options
  2. Go to Source Control –> Visual Studio Team Foundation
    image
  3. Click on “Configure User Tools…”
     image
  4. Click “Add…”  Then type in the following:
    Extension: .*
    Operation: Make sure it is set to “Compare”
    Command: diffmerge.exe
    Arguments: /ignorespace %1 %2
    image
  5. Click on all the “OK” buttons after that.  Now if you compare two different versions of a file, it will ignore the whitespace.