dev.e.loper
dev.e.loper

Reputation: 36044

TFS shortcut to compare a modified file with the latest version

Right now I have to pull up Pending Changes window, right-click on the file and select Compare->With Latest Version... Is there a faster way to look at my modifications?

Upvotes: 29

Views: 9767

Answers (4)

Sam
Sam

Reputation: 27354

Keyboard Shortcut for doing TFS Compare

In the Team Explorer window under Pending Changes:

  • shift + enter on file
    • will compare the files
  • shift + double click on file
    • will compare file in background
  • Create visual studio mapping for the commands:

Set the shortcut for compare folder under Source Control Explorer, you should set the shortcut keys for File.TfsFolderDiff command.

Set the shortcut for compare specific file under Source Control Explorer, you should set the shortcut keys for File.TfsCompare command

Note: To set the keyboard shortcuts, open "Tools > Options". In the dialog that opens, go to "Keyboard". Example:

Note: The folder compare shortcut is only valid from the "Source Control Explorer". It is the same as right clicking in the "Source Control Explorer" and selecting "Compare...".

How to apply keyboard shortcut

References:

Upvotes: 53

haku
haku

Reputation: 4505

Another alternative could be to set up an alias in Command Window and use it. To bring up the compare window: Open Command Window (ctrl + alt + A) Set alias for File.TfsCompare

alias diff File.TfsCompare

Next time you need to do the compare, type 'diff' and hit enter in the command window. 'diff' is an alias name, could be set to whatever of your choice. If you want to delete alias, use

alias aliasName /d

Upvotes: 0

Richard Banks
Richard Banks

Reputation: 12546

You can switch the double-click behaviour in the pending changes window to do a compare with latest by changing a registry setting:

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

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

You can find more information here:

A comment on that post also shows the entry to set if you want to use a shortcut key to do the comparison instead.

Upvotes: 27

Jason Williams
Jason Williams

Reputation: 57902

You can add hotkey bindings for TFS context menu commands, which may be an approach that will work for what you need.

Go to Tools > Options > Keyboard. In the 'filter' field, type 'TFS' and it'll show a list of all TFS commands that you can bind hotkeys to. The Source Control comparison ones can be shortlisted with "CompareWith". I've bound hotkeys in this way to the pending changes window's context menu, which is a great timesaver versus working your way down that tortuous context menu, but there may be other options that suit your needs better.

Upvotes: 3

Related Questions