33

When not running an application, pressing F12 (Go To Definition) on a method on an interface type will take you to the interface itself.

Is there any key combo that exists (or one that I can make) that will allow me to provide a default implementation to jump to, or allow me to quickly pick an implementation to go to?

We have several layers in our application, and it would save a lot of time to be able to jump straight to the Mock or Real implementations rather than navigating to them in source control.

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
Jonesopolis
  • 25,034
  • 12
  • 68
  • 112

6 Answers6

32

Visual Studio 2015 - Update 1

Added Edit.GoToImplementation which appeared in the context menu, but there was no keyboard shortcut associated with it by default.

Visual Studio 2015 - Update 2

Added a default shortcut of Ctrl + F12

KyleMit
  • 30,350
  • 66
  • 462
  • 664
Kevin Pilch
  • 11,485
  • 1
  • 39
  • 41
22

If using VS 2015 and above:

See other answer:

Visual Studio 2015 Update 1 added Edit.GoToImplementation which appeared in the context menu, but there was no keyboard shortcut associated with it by default.

In Visual Studio Update 2, we added a default shortcut of Ctrl+F12.


If using VS 2013 and below:

We had the same problem and started using Resharper. It has a nice Goto Implementation feature, which was working very well, as I remember.

The problem is that this tool is not free though (which is of course justified, as it offers much, much more than the mentioned feature).

Without this, I use Find All References and identify the implementation quickly by looking at the path (we have interfaces, implementations and mocks nicely segregated). But you've probably identified this possibility by yourself.

Also, you may consider an option mentioned in this answer (although it's for interface methods, not implementations):

  • move the cursor over the method
  • type CTRL+K CTRL+T to open the Call Hierarchy window
  • move down to Implements node
  • type Return to go to the selected implementation
StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
BartoszKP
  • 34,786
  • 15
  • 102
  • 130
15

Just press CTRL+F12 instead of just F12. This will take you directly to the implementation.

MaciejLisCK
  • 3,706
  • 5
  • 32
  • 39
13

Visual Studio 2015 has an "Edit.GoToImplementation" command that you can apply a keyboard shortcut to.

Tools / Options / Environment / Keyboard, then enter "Edit.GoToImplementation" into the show commands textbox. I use Shift+F12, so I change "Use new shortcut in" to Text Editor, then in "Press shortcut keys" I press Shift+F12 and click "Assign".

QueueHammer
  • 10,515
  • 12
  • 67
  • 91
Steve S
  • 614
  • 9
  • 20
  • Worked for me, thanks. If the shortcut CTRL+F12 is already set, then delete it, close the "Options" dialog box and try again with the same shortcut combination. – Mohammad Apr 30 '20 at 09:36
2

If the keybinding is set and it is still not taking you to the implementation, make sure no other application has the same keybinding. In my case, CTRL+F12 was also used by DeskPins. Cost me a few minutes until I found it.

Ben K.
  • 98
  • 1
  • 9
0

As others have mentioned in this post, CTRL+F12 will take you to the implementation. But if you're on a laptop or a device without dedicated function keys, don't forget to press the function key as well to get around the secondary controls F12 might have.

eg: FN+CTRL+F12

In my case, I thought I was pressing CTRL+F12 but was really pressing CTRL+end. This took me a few minutes to figure out so I figured others could use it too.

Casey
  • 1