views:

1907

answers:

11

After working for a few days with Eclipse Java I totally got addicted to pressing Ctrl and clicking on an identifier to go to its definition. Since then I've been looking for a way to achieve this in Visual Studio as well.

I realize VS has right click, Go to definition, and that F12 does the same. I also realize that Visual Assist does something similar with Alt+G. Yet none of these are as perfect as Ctrl+click.

I've actually tried my luck for a few hours trying to write a VS plugin to do it but didn't get anywhere in the time frame I thought reasonable for this.

Does anyone know how this could be achieved? A ready plugin? A macro of some kind?

+1  A: 

I don't work in VS much, so I haven't used it, but I've heard incredibly good things about Resharper from everyone I know who does. Everyone has told me it's worth every penny, and significantly improves efficiency in Visual Studio. I think it has a feature like what you're looking for, along with a TON of others.

Herms
+7  A: 

I'll answer the commentors who asked about the difference between ctrl-click and F12.

Ctrl-click workflow:

  • Move hand to mouse
  • Move mouse to hover over variable name
  • Other hand holds down ctrl key while you click
  • Move mouse to position cursor, highlight, right-click, or whatever
  • Move hand back to keyboard to continue typing

F12 workflow

  • Move hand to mouse
  • Mouse mouse to hover over variable name
  • Move hand back to keyboard
  • Hit F12 key
  • Move hand back to mouse
  • Move mouse to position cursor, highlight, right-click, or whatever
  • Move hand back to keyboard to continue typing

If you assume the cursor is already positioned on the desired variable, F12 is better. However, that's rarely the case. Also, if you stop after this specific action, assuming you want hands back at the keyboard, the cost is the same. But if you keep in mind that you probably had a reason for wanting to go to the definition, the ctrl-click workflow saves you an instance of moving between the keyboard and mouse.

Joel Coehoorn
A: 

I must be missing something because I don't see how Eclipse's ctrl-click feature (as described) is any better than Visual Studio's right-click-go-to-definition which requires fewer steps and can be done with one hand.

jwfearn
Visual Studio can take seemingly ages to bring up the right-click context menu sometimes.
Joel Coehoorn
Strange. I have not seen this in any version of VS.NET on my machine(s). The only time I have seen this was on a friend's machine. He had installed an add-in that caused a slow creation of the context menu due to the fact it was doing some sort of context-related computations.
joseph.ferris
+2  A: 

I use the built in options (F12, Right-click -> Go to definition) but I know a lot of the guys at my company use Resharper and it definitely has this functionality.

Danny Tuppeny
+1  A: 

Another option with VS (besides F12 and right-click > Go to Def) is add the code definition pane (View > Code Def Window). This is essentially another editing pane that shows the code for the current symbol - no need to ctrl-click or anything. I keep it pinned to my secondary monitor. Any time I need to see the implementation for a symbol I just click it and look over.

Another nice thing about F12 is you can also do Shift-F12 to find references to a symbol and F8 through them. The two go together like love and happiness.

fatcat1111
A: 

See also this question.

criddell
+1  A: 

right click + go to definition requires 2 steps from the same hand. ctrl+click can be done in one step (using both hands). way better! I really miss ctrl+click in VS :-(

Using both hands means that I need to put either my coffee, Coke, or smoke down - depending on where and when I am working. I'll pass! ;-)
joseph.ferris
+4  A: 

Visual Assist supports Ctrl+Click as of June 2009 (build 1727).

sean e
Ctrl+Left click invokes Goto (Alt+G) when this option is set under VA Options | Advanced | General.
mhenry1384
+1  A: 

oh man, just install resharper!! (vs plugin) with it installed you just go and ctrl + click to go to definition.

this is not the only thing resharper does, try it out free!!!

Diego
+4  A: 

If you use Visual Studio 2010, you can use the free Visual Studio 2010 Productivity Power Tools from Microsoft to achieve this.

splintor
After installing this VS 2010 extension, go to Options > Productivity Power Tools to see all the good stuff ('Ctrl-Click Go To Definition' is enabled by default).
RaceFace
A: 

If you have Visual Studio 2010 you can use "Go To Definition" by Noah Richards.

http://visualstudiogallery.msdn.microsoft.com/en-us/4b286b9c-4dd5-416b-b143-e31d36dc622b

mhenry1384