Blorgbeard
Blorgbeard

Reputation: 103447

How can I make control+click do a "Go To Definition"?

In the Delphi IDE you can hold CTRL and click on a method to jump to its definition. In Visual Studio 2008 you have to right-click and select "Go To Definition". I want to get Visual Studio to behave like Delphi in this regard.

Is there a way to get this working in Visual Studio 2008? Click then F12 does work but is slower than CTRL+click.

Upvotes: 19

Views: 8630

Answers (7)

RWendi
RWendi

Reputation: 1422

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

Upvotes: -1

doogie
doogie

Reputation: 601

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.

Upvotes: 2

splintor
splintor

Reputation: 10154

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.

Upvotes: 8

Catalin DICU
Catalin DICU

Reputation: 4638

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

Upvotes: 6

Tianhao Qiu
Tianhao Qiu

Reputation: 41

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.

Upvotes: 4

badp
badp

Reputation: 11813

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.

Upvotes: 6

Raithlin
Raithlin

Reputation: 1764

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.

Upvotes: 6

Related Questions