19

In the Delphi IDE, you can hold control and click on a method to jump to its definition. In VS2008, you have to right-click and select "Go To Definition".

I use this function quite often, so I'd really like to get VS to behave like Delphi in this regard - its so much quicker to ctrl+click.

I don't think there's a way to get this working in base VS2008 - am I wrong? Or maybe there's a plugin I could use?

Edit: Click then F12 does work - but isn't really a good solution for me.. It's still way slower than ctrl+click. I might try AutoHotkey, since I'm already running it for something else.

Edit: AutoHotkey worked for me. Here's my script:

SetTitleMatchMode RegEx
#IfWinActive, .* - Microsoft Visual Studio
^LButton::Send {click}{f12}
Blorgbeard
  • 101,031
  • 48
  • 228
  • 272

7 Answers7

8

Not for Visual Studio 2008, but if you upgrade to Visual Studio 2010, you can use the free Visual Studio 2010 Pro Power Tools from Microsoft to achieve this.

splintor
  • 9,924
  • 6
  • 74
  • 89
  • Gaaah.. took me forever to find this. I needed to disable ctrl-click. drives me bonkers when I'm trying to paste stuff.. Thanks – Rob Mar 19 '12 at 15:37
  • 1
    For Visual Studio 2015 use [Productivity Power Tools 2015](https://visualstudiogallery.msdn.microsoft.com/34ebc6a2-2777-421d-8914-e29c1dfa7f5d) – Marco Lackovic Apr 12 '16 at 14:01
6

Visual Studio 2008 defaults this to F12, but you can set it in Tools | Options | Environment | Keyboard, and change Edit.GoToDefinition - however, I'm not sure how you can get it to CTRL+mouseclick.

Raithlin
  • 1,764
  • 10
  • 19
  • 1
    IMO you should be the accepted answer (I know this is an old post). This is free and does what the OP wanted without writing a script or anything else....nice suggestion. – Jared Sep 25 '11 at 20:45
  • 1
    @Jared, it's a good tip, but it's not possible to bind to Ctrl+Click, so it doesn't quite do it for me. – Blorgbeard Apr 25 '12 at 21:45
6

Resharper does that but it's not free. Highly recommended plugin though, most experienced .NET developers use it.

Zach Johnson
  • 23,678
  • 6
  • 69
  • 86
Catalin DICU
  • 4,610
  • 5
  • 34
  • 47
6

You could create an Autohotkey script that does that. When you ctrl-click a word, send a doubleclick then a F12.

I don't have AHK handy so I can't try and sketch some code but it should be pretty easy; the AHK recorder should have enough features to let you create it in a point 'n' click fashion and IIRC it is smart enough to let you limit this behaviour to windows of a certain class only.

When you have your script ready just run the script in the background while you code. It takes just an icon in the Notify bar.

badp
  • 11,409
  • 3
  • 61
  • 89
4

Just a quick note that the following AutoHotkey script works for me in Visual C++ 2010 Express.

SetTitleMatchMode 2
#IfWinActive, Microsoft Visual C++ 2010 Express
^LButton::Send {click}{f12}

I also changed the shortcuts for View.NavigateForward and View.NavigateBackward to Alt+Right/Left Arrow since I am used to Eclipse.

2

Yes, both Resharper (a must have!) and Productivity Power Tools have this feature.

Interesting quirk, though.

If you just go with the defaults on both tools (if you install both tools) you can experience a frequent double-jump problem (jump to definition from where you first click and then jump again from what your cursor is above upon getting to that first definition) until you turn off one of the Ctrl-Click features of these add-ons.

doogie
  • 591
  • 4
  • 4
  • 1
    This is possibly one of the most helpful posts I've found all year on SO. The double-jumping has been driving me absolutely off the wall. Thanks so much! – Brett Widmeier May 09 '12 at 15:42
  • Glad I could help, Brett. That double jumping was a frustrating productivity killer. – doogie Jul 31 '12 at 20:57
-1

Put the mouse cursor on the method name or any identifier, and press F12

p.campbell
  • 98,673
  • 67
  • 256
  • 322
RWendi
  • 1,446
  • 5
  • 20
  • 38