How to ignore white space when comparing source in Visual Studio / TFS? - visual-studio-2010

The compare tool in Visual Source Safe (pre TFS) had a handy checkbox to select "Ignore White Space".
Now we are using TFS with Visual Studio 2010, and the compare dialog no longer has this option. (A ridiculous oversight from Microsoft!)
So, is it possible somehow to work around this?

This is a workaround that seems to get around the problem.
In Visual Studio, select Tools / Options / Source Control / Visual Studio Team Foundation System and click the Configure User Tools button.
In the dialog, Add an item with the following settings.
Extension : .*
Operation : Compare
Command : C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\diffmerge.exe
Arguments : %1 %2 %6 %7 %5 /ignorespace
Edit:
Depending on your Visual Studio version and instalation path (x64/x86), the command option may be...
VS2010: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\diffmerge.exe
VS2012: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\diffmerge.exe
VS2013: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsDiffMerge.exe
VS2015: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\vsDiffMerge.exe
VS2017: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\vsDiffMerge.exe
In the argument option leave it with the same number of arguments as the VS suggests and just add /ignorespace in the end. For example, in the VS2015 it will be:
%1 %2 /ignorespace

There is a "=" button on Visual Studio 2017 toolbar that helps to compare files as you want. Hope this screenshot will help.

The default diff tool in Visual Studio is extremely annoying. I suggest you use an alternative.
WinMerge is my favourite. It also has an option to ignore whitespace (menu Edit -> Options -> Compare -> Ignore all (under the groupbox "Whitespace" at the top)).
See Using WinMerge with TFS.

In VS2015 it's possible to "ignore white space" when comparing clicking a little icon with the = symbol.
Go to "View/Toolbars/Compare Files". In the toolbar click on "Ignore trim whitespace".
Update 2020: we struggled a lot solving conflicts with VS comparison tool and the Tortoise SVN one, so after a research we decided to install Devart Code Compare (free version) which has integration with VS2015/2017/2019, SVN (Tortoise and Ankh), TFS, Mercurial, GIT, etc. and Windows Explorer, so no more nightmares/confusion between different comparisons tools. Give it a try, it's extremely useful. It has also Merge to solve conflicts and Folder diff, which is really useful when SVN does not merge for some reason. Also, clicking on the left/right arrows to copy the changes is a feature that I really like.
Below VS image is from Devart website, but in my case I setup Code Compare to open it outside VS instead of embedded, I think it behaves better. And in VS Options > Source Control > Subversion Environment, I have this:

The default diff tool in VS 2013 does let you ignore whitespace after all. Just run the standard differencing process. When Visual Studio brings up the differences, look on the toolbar, where you will see an icon that looks like a document with 5 dots under it, as shown below. This button toggles whether the displayed differences ignore white space. This worked well enough for me; I wanted it to ignore changes in the white space caused by indentation.

in VS 2012, this might be what you're looking for with no changes to Diff tool.
Opening up the compare screen in VS 2012 and at the top you see the following option in the toolbar. as it might be the same comparison as user: Master screenshot.

Related

Remove Whitespace Before Committing Files to TFS

Visual Studio gives us this great ability to completely customize our work environment, including how we wish to format whitespace. I am very particular about how and where I want tabs, spaces, braces, etc. to appear.
For instance, I prefer tabs to be inserted as tabs not spaces. I also prefer the indentation (Tab size/Indent size) to only be 2 spaces (frankly I don't need 4 spaces to see that the line has been indented).
This is all well and good until I work collaboratively. Everyone else I work with just seem to use the defaults for whitespace/formatting. This causes problems when using source control like TFS. If you compare files worked on by me and then a co-worker, the changes in whitespace also show up. I don't want to see these changes; they're not significant.
Please don't tell me the answer is that the entire team should use the same settings. This isn't the correct answer. That answer is a cop-out for bad design. Why have the ability to customize your environment if everyone is forced to use the same settings?
Why doesn't TFS (or any other source control) remove unnecessary whitespace before committing a file based upon the file type? This has several benefits. One, the storage required to hold the file is less. Two, the transmission of the file to the source control server should be more efficient since the file is smaller (these first two benefits are probably negligible since the files are probably compressed anyway). Three, and most importantly, TFS (or any source control) will no longer report changes in whitespace when doing a file diff.
When I view/edit the file in my environment, it will be reformatted how I've defined it. When someone else views/edits the file, it will be reformatted to their specification.
Is there a way to do this currently in TFS?
Although what you said about is very reasonable, I still want to say the best solution is to get the entire team to use the same standards for white space in code. After all, you are teams.
If you insist on it, below is a workaround that to this problem (only works on your local machine).
In Visual Studio, select Tools / Options / Source Control / Visual Studio Team Foundation System and click the Configure User Tools button.
In the dialog, Add an item with the following settings.
Extension : .*
Operation : Compare
Command : C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\diffmerge.exe
Arguments : %1 %2 %6 %7 %5 /ignorespace
Depending on your Visual Studio version and instalation path (x64/x86), the command option may be...
VS2010: C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\diffmerge.exe
VS2012: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\diffmerge.exe
VS2013: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsDiffMerge.exe
VS2015: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\vsDiffMerge.exe
In the argument option leave it with the same number of arguments as the VS suggests and just add /ignorespace in the end. For example, in the VS2015 it will be:
%1 %2 /ignorespace
More details you can refer this blog: Configure Diff to Show Whitespace
You could also use another alternative. WinMerge is. It also has an option to ignore whitespace (menu Edit -> Options -> Compare -> Ignore all (under the groupbox "Whitespace" at the top)).
How to use WinMerge with TFS you can refer:
Using WinMerge with Team Foundation Server (TFS)
Using WinMerge as the default diff/merge tool in Visual Studio
2012/2013

how to compare two files in visual studio ignoring casing

I want to compare two files in visual studio (files containing stored procs)
So I want to ignore all the "Capital" / "Small" differences in the file.
I opened the command window and used Tools.DiffFiles but its taking the case difference also into consideration
P.S I have already seen this question and answers for it
Although Visual Studio is asked for explicitly, I recommend a different tool: WinMerge.
It indeed has many options for comparing and merging files. It lacks a 3-way-merge though. Of course WinMerge can optionally ignore case.
Visual Studio can be configured so you can call WinMerge using "Tools / External Tools ...". Then you may even install a toolbar item for it. Quite nice!
Most version control systems allow you to use WinMerge as a compare tool. For example for TFS you open the "Tools / Options ..." menu and there you choose "Source Control / Visual Studio Team Foundation Server". Click on the button "Configure User Tools".

Assign .vcproj files to Visual Studio 2008, when Visual Studio 2010 installed

I have encountered a strange error. I use Windows 7 x64. Visual Studio 2010 (VS10) and Visual Studio 2008 (VS08) are both installed. Now i want to make sure that when i doubleclick open a .vcproj file it is being opened by VS8 and not VS10. Now this seems like a trivial problem, but:
"righclick -> open with -> choose default program -> select devenv.exe of VS08 -> always open with" doesnt work. In fact after browsing for devenv.exe of VS08 it does not show up in the list/menue where it is supposed to be displayed.
This is very strange and annoying, maybe someone already encountered this error and know a solution.
I GOT IT! For the Express versions at least. I strongly suspect these instructions can be modified to apply to the full version. The names will change of course.
I spent a lot more time on this than I will ever save by being able to click through to the correct IDE, but darn it, I just hate to give up.
Here's the deal. Strangely, the associations seem to be keyed to the program file names. (Say, what?? That sure is the way it looks to me.) Both VC++ Express 2008 and 2010 are named VCExpress.exe. We'll give the 2008 version an alias. We'll also use a doppelganger to pull off something of a ruse.
Navigate to "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE". Make a copy of VCExpress.exe, (not a shortcut), and re-name it VCExpress-2008.exe. (It would probably do just to re-name the original and use the new name in step 3.)
Open regedit.exe. Create a new key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\VSExpress-2008.exe
Edit the (default) value in that key, to hold the string "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\VCExpress.exe" [sic]
Go through the drill with the file-association dialog again. Right-click, open with, choose default program, yada, yada, yada. Browse your way down to C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE and click on VSExpress-2008.exe.
VCExpress-2008 now shows up as a program in good standing, with its icon proudly displayed on the front page above the fold. (Don't tell the dialog, but you and I know it really points to VCExpress.exe, not the copy we made.) Click it.
Celebrate.
Ok i finally found a way. You can use the application "default programs editor" to mess with the standard file associations.

Is it possible to use WinMerge inside Visual Studio 2008 and Visual Source Safe 6.0?

I would like to use WinMerge as the default diff tool inside VS2008 from the solutions explorer in place of the "Compare..." context menu item. Is this possible? I'm looking for a quick replacement of the current bland diff tool an I just like WinMerge better. I'm not interested in going to the folder explorer and doing the comparison there.
I'm using Visual Source Safe 6.0 not TFS
Yep, it's possible!
See this link: http://whyiamright.wordpress.com/2008/01/18/changing-the-diffmerge-program-used-by-visual-studio/
Tools-> Options. In the tree, choose Source Control, then the plugin of your choice (VS team Foundation, Source Safe, etc).
Click the "Configure User Tools" button, click add, then specify the appropriate extension, operation, EXE, and arguments list.
This site: has the settings for many, including winmerge: http://blogs.msdn.com/jmanning/articles/535573.aspx
EDIT:
You mentioned VSS: Check out the Winmerge manual here: http://winmerge.org/docs/manual/VersionControl.html. It says how to do it about 1/5th the way down the page.
I think I have this working at a serviceable level if not optimal.
in visual studio go to tools > options > source control > plug-in settings
click the "advanced" button
in the sourcesafe options dialog, switch to the "custom editors" tab
for operation, select file difference
for file extension enter .*
for command line enter
"C:\Program Files\WinMerge\WinMergeU.exe" /x /e /ub /wl /dl %6 /dr %7 %1 %2
click the "add" button then the "ok" button.
using "compare" from a file's context menu or viewing history and selecting "diff" should bring up winmerge with the file comparison. the original is on the left and the modified file is on the right (is that the right placement? should they be swapped?). if you selected a highlighted difference, you can actually sync that area at this time as well. visual studio will just recognize the file has changed and ask you to reload. I haven't gotten to the situation where I'm in an actual "merge" situation so I'm not sure what happens there. I'll update this post if I ever have more info to add.
I'm using VS2008, sourcesafe 2005, and winmerge 2.12.4 installed to the default directory. I copied the settings from this post: http://weblogs.asp.net/garrypilkington/archive/2009/12/16/winmerge-as-a-comparison-tool-in-visual-studio-2008.aspx
I have been wondering about this as well and have not found anything to make it possible in VSS 6.0.
For now, it looks like the answer to our question is "No".
As I stated previously, I don't think we can integrate WinMerge with Visual Studio 2008 and VSS 6.0.
However, I did find that VSS 2005 is backward compatible with VSS 6.0 databases. So, if your server can't change from VSS 6.0, at least perhaps you can change your client to VSS 2005, and then follow the other instructions from the answers here.

How do you clear your MRU list in Visual Studio?

I want to clear the list of projects on the start page...how do I do this? I know I can track it down in the registry, but is there an approved route to go?
There is an MSDN article here which suggests that you just move the projects to a new directory.
However, as you mentioned, the list of projects is kept in the registry under this key:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\<version>\ProjectMRUList
and the list of recent files is kept in this key:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\<version>\FILEMRUList
Note For Visual Studio 2015:
The location has changed. You can check out this answer for details.
Some people have automated clearing this registry key with their own tools:
Visual Studio Most Recent Files Utility
Add-in for cleaning Visual Studio 2008 MRU Projects list
PowerCommands for Visual Studio 2008
Features
Clear Recent File List
Clear Recent Project List
Clear All Panes
Copy Path
Email CodeSnippet
Insert Guid Attribute
Show All Files
Undo Close
Collapse Projects
Copy Class
Paste Class
Copy References
Paste References
Copy As Project Reference
Edit Project File
Open Containing Folder
Open Command Prompt
Unload Projects
Reload Projects
Remove and Sort Usings
Extract Constant
Transform Templates
Close All
If you try opening up a project that can no longer be found, Visual Studio will prompt you for permission to remove it from the MRU list. So if you temporarily rename an appropriate top level folder to fake the projects' disappearance, you can get rid of the projects one by one.
In Visual Studio 2015 all the history lists (including search history, file MRU and project MRU) are now located at:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\MRUItems
You will see a different GUID folder for each list, and a sub-folder called Items in each of them. Find the Items folder that contains the relevant list, and just delete its parent GUID folder.
Visual Studio will re-create the GUID folder together with a new Items child folder, next time it wants to add something to the list again.
I found the MRU editor from Code Project a great tool for that. No problems with it, and it works on 2003, 2005, and 2008.
Note: This answer is specific to Visual Studio 2010.
If you don't want to manually edit the registry, you can use PowerCommands for Visual Studio 2010.
PowerCommands 10.0 is a set of useful extensions for the Visual Studio
2010 adding additional functionality to various areas of the IDE.
The specific command for clearing the registry from the extension is:
Clear Recent Project List This command clears the Visual Studio recent project list. The Clear Recent Project List command brings up a
Clear File dialog which allows any or all recent projects to be
selected.
The PowerCommands can be installed with the Visual Studio extension manager: Tools > Extension Manager > Online Gallery: search for PowerCommands for Visual Studio 2010.
Try Recently Used Files: a free addin for Visual Studio that manages MRU files on a per-project basis:
Supported for VS 2010, 2012, 2013.
For Visual Studio 2012, 2013:
http://visualstudiogallery.msdn.microsoft.com/a61cbd1d-b5a2-490b-a6bb-f0ea3ecf214a
For Visual Studio 2010:
http://visualstudiogallery.msdn.microsoft.com/45283881-5a62-4dc1-8ffb-4cbc02709947
For Visual Studio 2013:
Open the Run dialog (Press Win + R)
type: regedit
navigate to: HKEY_CURRENT_USER > Software > Microsoft > VisualStudio
click 12.0 then the files will show up on the right side.
Look for the "LastLoadedSolution", right click then click Modify
change the value to 0.
This worked for me.
I'm not sure if this solution has been posted somewhere here, but if you have VS 2013 Update 5 you can open start page, and right click project below "Recent" list, and choose "Remove from list". I don't know how about other VS versions, maybe this feature is available.
I had this issue as applied to VS 2017 where you do not have any MRU items in the registry as in the previous versions. The solution was, on the other hand, simple: go to "Tools->Extensions and Updates" and install "Power Commands for Visual Studio". After they have been installed, your File menu will look as shown below.
Just click the menu item to clear the project MRU.

Resources