Jehof
Jehof

Reputation: 35544

Compare files on double click in Pending Changes view

Is there a way in visual studio to change the behavior when I double click a file in the 'Pending Changes' view.

The default behavior is, that Visual Studio opens the file in code editor, but I want that it opens the 'Compare'-Dialog with the latest version. (same behavior as in TortoiseSVN)

Upvotes: 62

Views: 7998

Answers (9)

Console
Console

Reputation: 65

In all versions, you can:

  • double click for one action
  • click, then Shift + Double Click to perform the alternate action

In later versions of Visual Studio (including 2019 and 2022), you can also change the default double click action in the git changes window without messing around with registry changes:

  • Go to the "Git Changes" window
  • On the line where it says "Changes", click the three dots "..." on the right (immediately to the right of a plus button)
  • Select the first option. The option will alternate between "Compare File as Default Action" and "Open File as Default Action"

Screenshot

Upvotes: 6

icrf
icrf

Reputation: 364

Slight update for 2022, as there doesn't seem to be a vswhere.exe to pull a version number, and it's 64-bit. I haven't looked to see if there's another option to pull that, but for the once-in-an-install task, I'm okay with two steps and a manual copy/paste.

Same close Visual Studio instances and wait at least a few seconds for it to unload the registry, and open a Powershell as admin. Run this first to find your version number.

dir $env:LOCALAPPDATA\Microsoft\VisualStudio\

Then add it to the $version string and run the rest below.

$version = "17.0_[*some key*]"
reg.exe load HKLM\VSPrivateRegistry $env:LOCALAPPDATA\Microsoft\VisualStudio\$version\privateregistry.bin
reg.exe add HKLM\VSPrivateRegistry\Software\Microsoft\VisualStudio\$version\TeamFoundation\SourceControl\Behavior /v DoubleClickOnChange /t REG_DWORD /d 1 /f
reg.exe unload HKLM\VSPrivateRegistry

Maybe this method will be more shelf-stable for future versions, though judging from the history of this page, I shouldn't expect that.

Upvotes: 1

Anish
Anish

Reputation: 464

The steps from VS2017 onward are a bit different. VS 2017 uses its own private registry, which is stored in your AppData folder.

Steps

  1. Close all visual studio instances

  2. Select the HKEY_USERS node, and click File > Load Hive

  3. Open privateregistry.bin which can be found at %UserProfile%\AppData\Local\Microsoft\VisualStudio\15.0_[*some key*]

  4. Provide a key name. Eg VS2017PrivateRegistry

  5. Navigate to the following path and create a new DWORD with value of 1.

    Path:HKEY_USERS\VS2017PrivateRegistry\Software\Microsoft\VisualStudio\15.0_[*some key*]\TeamFoundation\SourceControl\Behavior

    Value: DoubleClickOnChange (DWORD) 1

  6. Select HKEY_USERS\VS2017PrivateRegistry

  7. Click File > Unload Hive

Upvotes: 18

Daryl
Daryl

Reputation: 18895

VS 2019 And Beyond (hopefully)

Building on Tereza's answer using powershell

Run powershell as adminstrator and close Visual Studio. (you might have to wait a couple of seconds for VS to release some files) (if you copy paste make sure to send the last command, or else VS won't start)

$instanceId = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property instanceId).Trim()
$versionMajor = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationVersion).Trim().Substring(0,2)
$year = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property catalog_productLineVersion).Trim()
reg.exe load HKLM\VS$yearPrivateRegistry $env:LOCALAPPDATA\Microsoft\VisualStudio\$versionMajor.0_$instanceId\privateregistry.bin
reg.exe add HKLM\VS$yearPrivateRegistry\Software\Microsoft\VisualStudio\$versionMajor.0_$instanceId\TeamFoundation\SourceControl\Behavior /v DoubleClickOnChange /t REG_DWORD /d 1 /f
reg.exe unload HKLM\VS$yearPrivateRegistry

This attempts to determine the major version as well.

Upvotes: 8

Tereza Tomcova
Tereza Tomcova

Reputation: 5078

VS 2017

This PowerShell script should turn this on for the latest installed instance (adapted from Anish's answer)

You'll need to close all VS instances first.

$instanceId = $(& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property instanceId).Trim()
reg.exe load HKLM\VS2017PrivateRegistry $env:LOCALAPPDATA\Microsoft\VisualStudio\15.0_$instanceId\privateregistry.bin
reg.exe add HKLM\VS2017PrivateRegistry\Software\Microsoft\VisualStudio\15.0_$instanceId\TeamFoundation\SourceControl\Behavior /v DoubleClickOnChange /t REG_DWORD /d 1 /f
reg.exe unload HKLM\VS2017PrivateRegistry

VS 2015 or older

This PowerShell command should turn this on for all installed versions:

Set-ItemProperty HKCU:\Software\Microsoft\VisualStudio\*\TeamFoundation\SourceControl\Behavior DoubleClickOnChange 1

Upvotes: 9

FryGuy
FryGuy

Reputation: 8744

There is a way to make this permanent so you don't need to shift + double-click: http://www.richard-banks.org/2010/07/how-to-double-click-to-diff-pending.html

Path: HKCU\Software\Microsoft\VisualStudio\<ver>\TeamFoundation\SourceControl\Behavior
Value: DoubleClickOnChange (DWORD)

0 == view as the primary command (default)
1 == compare as primary command

Upvotes: 65

Ralph Willgoss
Ralph Willgoss

Reputation: 12163

You could also apply some Visual Studio keyboard short cuts for the various comparison types - Latest, WorkSpace and Previous.

See the following post: Comparison keyboard shortcuts for Pending Changes in TFS

Upvotes: 2

Andre Pena
Andre Pena

Reputation: 59336

Put this on a .reg file and and double click it, this will make your double click compare instead of opening the file in the pending changes window.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\TeamFoundation\SourceControl\Behavior]
"DoubleClickOnChange"=dword:00000001

Make sure the Visual Studio version is correct.

Upvotes: 5

Noah Richards
Noah Richards

Reputation: 6867

Do shift + double-click instead.

Upvotes: 75

Related Questions