405

I would like to configure Visual Studio to open Beyond Compare by default as the diff tool. How can I do this?

MrBoJangles
  • 12,127
  • 17
  • 61
  • 79

11 Answers11

602

In Visual Studio, go to the Tools menu, select Options, expand Source Control, (In a TFS environment, click Visual Studio Team Foundation Server), and click on the Configure User Tools button.

image to show location of the Configure User Tools button

Click the Add button.

Enter/select the following options for Compare:

  • Extension: .*
  • Operation: Compare
  • Command: C:\Program Files\Beyond Compare 3\BComp.exe (replace with the proper path for your machine, including version number)
  • Arguments: %1 %2 /title1=%6 /title2=%7

If using Beyond Compare Professional (3-way Merge):

  • Extension: .*
  • Operation: Merge
  • Command: C:\Program Files\Beyond Compare 3\BComp.exe (replace with the proper path for your machine, including version number)
  • Arguments: %1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9

If using Beyond Compare v3/v4 Standard or Beyond Compare v2 (2-way Merge):

  • Extension: .*
  • Operation: Merge
  • Command: C:\Program Files\Beyond Compare 3\BComp.exe (replace with the proper path for your machine, including version number)
  • Arguments: %1 %2 /savetarget=%4 /title1=%6 /title2=%7

If you use tabs in Beyond Compare

If you run Beyond Compare in tabbed mode, it can get confused when you diff or merge more than one set of files at a time from Visual Studio. To fix this, you can add the argument /solo to the end of the arguments; this ensures each comparison opens in a new window, working around the issue with tabs.

schellack
  • 10,144
  • 1
  • 29
  • 33
  • 20
    Note that for Beyond Compare 3, you should actually be using BComp.exe -- see http://www.scootersoftware.com/vbulletin/showthread.php?t=3461 – Joe Jul 13 '11 at 15:28
  • 3
    Thanks for that info and link -- I updated my answer with the better executable name. – schellack Jul 13 '11 at 21:01
  • Could you add a screenshot showing this `Configure User Tools` button? Visual Studio 2010 has none. – Ian Boyd Nov 08 '11 at 19:57
  • 1
    I added a screenshot of the button in VS 2010 on my machine. Note that I'm using TFS. If you're not, then this will likely look different. – schellack Nov 09 '11 at 17:56
  • 7
    I updated this answer to support both Beyond Compare v3 Pro/Std and Beyond Compare v2 (v3 offers 3-way merge) and updated arguments from official BC website: http://www.scootersoftware.com/support.php?zz=kb_vcs – Evan Wondrasek Dec 08 '11 at 20:36
  • I updated with a parenthetical statement in the first sentence for the benefit of folks like myself who are in a TFS environment, just to clarify (the screenshot says as much anyway). – MrBoJangles Jan 03 '12 at 22:06
  • @Joe that link saved my life. I've had the problem that article describes for months and now it's fixed!!!!! So excited. – Ryan Rodemoyer Feb 15 '12 at 14:21
  • 35
    If you run Beyond Compare in tabbed mode, it can get confused when you diff or merge more than one set of files at a time from Visual Studio. To fix this, you can add the argument "/solo" to the end of the arguments; this ensures each comparison opens in a new window, working around the issue with tabs. – Josh Sklare Aug 23 '12 at 22:49
  • 1
    For those on x64 and too lazy to find it in Explorer: `C:\Program Files (x86)\Beyond Compare 3\BCompare.exe` – Chris S Nov 09 '12 at 10:06
  • This should work for VS 2012 as well, according to the answer here: http://stackoverflow.com/questions/13297790/how-to-configure-visual-studio-2012-to-use-beyond-compare-3 – MrBoJangles Feb 08 '13 at 16:03
  • 19
    When using the Git add-in for Visual Studio, there is no Configure User Tools button. Anyone know a way to hook Git add-in to use beyond compare? – Stephen Price Jun 02 '13 at 04:20
  • These instructions don't seem to be working anymore. Has something changed? I explain my problem in [this question](http://stackoverflow.com/questions/17091584/how-to-configure-visual-studio-tfs-to-use-beyondcompare3-broken) – kmote Jun 13 '13 at 15:56
  • @kmote looks like you figured out the problem you were having, that's good. – MrBoJangles Jun 14 '13 at 15:00
  • 9
    Beyond Compare 4 setup is the same, as is Visual Studio 2013. To support version 4, simply change the "3" in the COMMAND path to a "4". It's pretty obvious, but should be noted. For example, on my workstation, the path is: C:\Program Files (x86)\Beyond Compare 4\BCompare.exe – Mike Christian Sep 11 '14 at 16:21
  • Currently we are using TFS. So, I can go ahead with this method. But, soon Git will replace TFS in our organization. So, can anyone let me know how to do it for Git? Thanks! – Vikram Oct 08 '14 at 15:48
  • 3
    To configure Git for Windows to use Beyond Compare as the external difference utility, follow the instructions at http://www.scootersoftware.com/support.php?zz=kb_vcs#gitwindows – schellack Nov 21 '14 at 21:41
  • 2
    @StephenPrice to use BC with Git inside VS check http://stackoverflow.com/questions/19461658/setting-up-beyond-compare-in-visual-studio-2013-when-using-git – demoncodemonkey Mar 11 '15 at 22:21
  • 1
    4.x C:\Program Files\Beyond Compare 4\BComp.exe – Tom Stickel Jul 07 '16 at 21:22
  • For Jazz Source Control do not forget to enable the Beyond Compare 4 by selecting "Use an external compare tool instead of the default compare utility" OTHER than "Never", e. g. "Always". – Dom Mar 02 '20 at 17:48
  • this is by far the most visited answer for me, ever – r3mark Jul 21 '20 at 04:15
  • Works. Please add VS Code: `code.exe --diff ` and `code.exe --merge `. – bers Jul 26 '23 at 14:14
  • Has this change with VS 2022 v17.7? When I rune any executable for merging with `%1 %2 %3 %4`, file `%4` seems to be missing in the file system. – bers Aug 23 '23 at 07:43
116

Visual Studio with Git for Windows

If you're using GIT as your source code management system instead of the (fairly dated) TFVC then Visual Studio doesn't have options to configure anything like this.
Instead it (rightly in my opinion) uses the GIT config file's setting. So if you already have GIT setup to use Beyond Compare or any other third party comparison software it will just pick this up and start using it.

If not then just set that up (see here for further and likely more up to date help). The relevant info for setting up Visual Studio with Beyond Compare 4 is:

  1. Open Visual Studio.
  2. Select Options from the Tools menu.
  3. Select Plug-In Settings under the Source Control branch of the left-side tree control.
  4. Select Microsoft Git Provider under Plug-In Settings on the right-hand pane.
  5. Edit the global git config file (location is OS specific for windows it's %HOMEDRIVE%%HOMEPATH%/.gitconfig. See here for info) OR if you want it to be repo specifict then after starting a project in a Git repository, edit the config file in the .git folder in the project folder.
  6. Change the config file to reflect the following changes:

    [diff]
        tool = bc4
    [difftool "bc4"]
        cmd = \"C:\\Program Files (x86)\\Beyond Compare 4\\BComp.exe\" \"$LOCAL\" \"$REMOTE\"
    [merge]
        tool = bc4
    [mergetool "bc4"]
        cmd = \"C:\\Program Files (x86)\\Beyond Compare 4\\BComp.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" 
    

If 64bit installer is used, verify the name of the executable. Mine was BCompare.exe

[diff]
    tool = bc4
[difftool "bc4"]
    cmd = \"C:\\Program Files\\Beyond Compare 4\\BCompare.exe\" \"$LOCAL\" \"$REMOTE\"
[merge]
    tool = bc4
[mergetool "bc4"]
    cmd = \"C:\\Program Files\\Beyond Compare 4\\BCompare.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"

Issues: If you create a new project and get VS to create the git repo at the same time it WILL add a load of overrides to the .git/config file forcing it to use Visual Studio again (Thanks for that MS!). SO either create the git repo via another means after the project has been setup (like via SourceTree or the command line etc...) OR edit the .git/config file (in the solution folder) and remove any overrides for the above settings.
Thanks to minnow in the comments for bringing my attention to it again.

Note: I keep coming across this but I am using VS with GIT and the answers aren't correct and although some of the comments mention a URL with the correct answer it's not clear and if I kept missing it I'm sure others will so hopefully this will solve that issue.

Andacious
  • 1,162
  • 10
  • 17
GazB
  • 3,510
  • 1
  • 36
  • 42
  • 1
    Very helpful, as I'm using Git for Windows. – MrBoJangles Jan 22 '16 at 17:32
  • 2
    Careful though - VS 2015, for me, set itself up as the diff/merge tool in the *local* git config file in the local repo....thus overriding the global. Just remove the entries in the local repo config and you should be good. – Jester Jan 23 '16 at 15:25
  • @Jester I'm not sure if that's a setting (although I have no idea where it would be as GIT doesn't seem to have any settings in VS2015!) as I just created a blank C# console app setting it to use GIT and did an initial check-in using VS2015 and the only files it created where `.gitattributes` and `.gitignore`. Can you replicate it with a new project and if so what kind of project is it? Would be interesting to see why we get different results. Oh also if you can replicate it what VS extensions do you have? Maybe they are the cause. :) – GazB Jan 25 '16 at 09:36
  • @Jester I'm using the NuGet Package Manager for Visual Studio 2015 Extension. I do have a local config at [repo]\.get\config, but it does not contain any diff or merge config. So making this change worked like a charm as soon as I realized that I'm on Beyond Compare 3; not 4. Thank you all so much! – Mark Bailey Feb 11 '16 at 17:10
  • 7
    Haha just tried to vote up this AMAZING answer... then it said "You can't vote on your own answer"... OH LOL God bless not having a memory! ;) – GazB Nov 28 '16 at 13:04
  • 6
    BC4 installed in a slightly different path, the 64b dir, on my machine: `\"C:\\Program Files\\Beyond Compare 4\\BComp.exe\"` – GraehamF Feb 08 '17 at 18:17
  • 1
    I found that setting the global git config didn't work at all. I had to modify the repo's config. VS2017. Anyone else experiencing the same? And @GazB, I suspect GraehamF, like me, just has the 64-bit version of BC installed on 64-bit windows, so the installed path is the correct, expected Program Files and not PF(x86). – minnow Dec 04 '17 at 05:23
  • @minnow I think I remember having that issue as well when I let VS create the .git repo. It adds a override in its repo config undoing our work! (Thanks MS!) but I tend to use SourceTree to create my repos now and use my own .gitignore files for each project. SO if you let VS create the .git repo on project creation (ticking that box in the new project setup) you will need to edit the `.git/config` file to remove the relevant lines that are forcing it to use VS again. :) If this is the case (I will do some checks when I get some time) I will update the answer to help others. Thanks minnow – GazB Dec 05 '17 at 17:05
  • Apparently VS caches the decision. So after you make these changes to your _.gitconfig_ you may need to restart VS or change the Source Control Plug-in from Tools-Options and set it back to git again. – keremispirli Nov 01 '18 at 14:51
  • The 64-bit version comes with _both_ BCompare.exe and bcomp.exe. You want to use bcomp.exe, to make sure it can work with multiple files. BCompare will work if you only want to compare a single file, but if you try to compare another file while BC is already open, it will fail. Using bcomp.exe allows it to work in all instances. – Elezar Feb 20 '20 at 17:58
  • @minnow: The reason modifying the global git config did not work is that your solution's .git folder has a config file (no file extension!)--and that specifies Visual Studio's built-in comparer by default, so it effectively overrides what you specified in the global .git file. Just remove the [diff], [difftool], [merge], and [mergetool] entries from your solution's config file and the global values will take over. – Jazimov Oct 18 '20 at 03:50
17

If you are using the TFS, you can find the more information in diff/merge configuration in Team Foundation - common Command and Argument values

It shows how to configure the following tools:

  • WinDiff
  • DiffDoc (for Word files)
  • WinMerge
  • Beyond Compare
  • KDiff3
  • Araxis
  • Compare It!
  • SourceGear DiffMerge
  • Beyond Compare 3
  • TortoiseMerge
  • Visual SlickEdit
fresky
  • 530
  • 5
  • 15
16

I got bored of doing this every 6 months when a new version of Visual Studio comes out, or I move PCs, or a new member joins the team. So, PowerShell:

# .Synopsys
# Sets up Beyond Compare professional as Diff tool for all instances of Visual Studio on this PC
# If you don't use TFS, change the sccProvider as appropriate
[CmdLetBinding()]
param(
    $bcPath = 'C:\Program Files (x86)\Beyond Compare 3\BComp.exe',
    $sccProvider = 'TeamFoundation'
)

$ErrorActionPreference = 'stop';
$baseKey = 'REGISTRY::\HKCU\Software\Microsoft\VisualStudio\*'

function SetRegKeyProperties($keyPath, [hashtable]$keyProps){
    if(!(Test-Path $keyPath)){
        Write-Verbose "Creating $keyPath"
        # Force required here to recursively create registry path
        [void] (new-item $keyPath -Type:Directory -Force);
    }
    foreach($prop in $keyProps.GetEnumerator()){
        Set-ItemProperty -Path:$keyPath -Name:$prop.Key -Value:$prop.Value;
    }
}

$configBases = dir $baseKey | ? { $_.PSChildName -match '^\d+\.\d$' }
foreach($item in $configBases){
    Write-Host "Configuring $item"

    $diffToolsKey = Join-Path $item.PSPath "$sccProvider\SourceControl\DiffTools"
    SetRegKeyProperties (Join-path $diffToolsKey '.*\Compare') @{Command=$bcPath;Arguments='%1 %2 /title1=%6 /title2=%7'}
    SetRegKeyProperties (Join-path $diffToolsKey '.*\Merge') @{Command=$bcPath;Arguments='%1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9'}
}

Works on my machine. YMMV. No warranties, no refunds. VS doesn't appear to cache the key, so takes effect immediately.

piers7
  • 4,174
  • 34
  • 47
  • 1
    These days its $bcPath = 'C:\Program Files (x86)\Beyond Compare 4\BCompare.exe' for the latest version. So if only that was combined with the chocolatey install... (thanks by the way) – James Woolfenden Nov 07 '14 at 09:23
  • This is great. Thanks so much for posting this information, will make life easier! – d3r3kk Nov 19 '15 at 16:48
  • 1
    Probably should just update to read the Registry entry: `computer\hkey_local_machine\scooter software\beyond compare\exepath`. – Erik Philips Jun 09 '16 at 16:14
  • Thanks, that is really useful! How would you do that with Visual Studio 2017 and newer? Because here a private registry is used (https://www.visualstudioextensibility.com/2017/07/15/about-the-new-privateregistry-bin-file-of-visual-studio-2017/). – MaDev Nov 10 '21 at 15:20
9

In Visual Studio 2008 + , go to the

Tools menu -->  select Options 

enter image description here

In Options Window --> expand Source Control --> Select Subversion User Tools --> Select Beyond Compare

and click OK button..

BJ Patel
  • 6,148
  • 11
  • 47
  • 81
3

I'm using VS 2017 with projects hosted with Git on visualstudio.com hosting (msdn)

The link above worked for me with the "GITHUB FOR WINDOWS" instructions.

http://www.scootersoftware.com/support.php?zz=kb_vcs#githubwindows

The config file was located where it indicated at "c:\users\username\.gitconfig" and I just changed the BC4's to BC3's for my situation and used the appropriate path:

C:/Program Files (x86)/Beyond Compare 3/bcomp.exe

chuckc
  • 181
  • 6
3

The answer posted by @schellack is perfect for most scenarios, but I wanted Beyond Compare to simulate the '2 Way merge with a result panel' view that Visual Studio uses in its own merge window.

This config hides the middle panel (which is unused in most cases AFAIK).

 %1 %2 "" %4 /title1=%6 /title2=%7 /title3="" /title4=%9

With thanks to Morgen

Ted
  • 2,525
  • 2
  • 37
  • 54
2

VS2013 on 64-bit Windows 7 requires these settings: Tools | Options | Source Control | Jazz Source Control

CHECK THE CHECKBOX Use an external compare tool ... (easy to miss this)

2-Way Compare Location of Executable: C:\Program Files (x86)\Beyond Compare 3\BCompare.exe

3-Way Conflict Compare Location of Executable: C:\Program Files (x86)\Beyond Compare 3\BCompare.exe

Arvind
  • 93
  • 8
2

BComp.exe works in multiple-tabbed scenario as well, so there is no need to add /solo unless you really want separate windows for each file comparison. Tested/verified on Beyond Compare 3 and 4. Moral: use BComp.exe, not BCompare.exe, for VS external compare tool configuration.

Arvind
  • 93
  • 8
2

I use BC3 for my git diff, but I'd also add vscode to the list of useful git diff tools. Some users prefer vscode over vs ide experience.

Using VS Code for Git Diff

git config --global diff.tool vscode
git config --global difftool.vscode.cmd "code --wait --diff $LOCAL $REMOTE"
SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
2

Can't comment because my reputation score is low.

Here's a waybackmachine link to Fresky's link

Dan
  • 41
  • 6