简体   繁体   English

在Visual Studio 2008中,如何进行控制+单击执行“转到定义”?

[英]In Visual Studio 2008, how can I make control+click do a “Go To Definition”?

In the Delphi IDE, you can hold control and click on a method to jump to its definition. 在Delphi IDE中,您可以保持控制并单击某个方法以跳转到其定义。 In VS2008, you have to right-click and select "Go To Definition". 在VS2008中,您必须右键单击并选择“转到定义”。

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. 我经常使用这个函数,所以我真的很想让VS在这方面表现得像Delphi一样 - 它可以更快地进行ctrl +点击。

I don't think there's a way to get this working in base VS2008 - am I wrong? 我认为有一种方法可以让它在VS2008基础上运行 - 我错了吗? 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. 编辑 :点击然后F12确实有效 - 但对我来说这不是一个很好的解决方案..它仍然比ctrl + click慢。 I might try AutoHotkey, since I'm already running it for something else. 我可能会尝试使用AutoHotkey,因为我已经在运行它了。

Edit : AutoHotkey worked for me. 编辑AutoHotkey为我工作。 Here's my script: 这是我的脚本:

SetTitleMatchMode RegEx
#IfWinActive, .* - Microsoft Visual Studio
^LButton::Send {click}{f12}

不适用于Visual Studio 2008,但如果升级到Visual Studio 2010,则可以使用Microsoft提供的免费Visual Studio 2010 Pro Power Tools来实现此目的。

Resharper does that but it's not free. Resharper做到了,但并不是免费的。 Highly recommended plugin though, most experienced .NET developers use it. 不过,强烈推荐的插件,大多数有经验的.NET开发人员都使用它。

You could create an Autohotkey script that does that. 您可以创建一个Autohotkey脚本来执行该操作。 When you ctrl-click a word, send a doubleclick then a F12. 当您按住Ctrl键单击某个单词时,请发送双击然后单击F12。

I don't have AHK handy so I can't try and sketch some code but it should be pretty easy; 我没有方便的AHK所以我不能尝试草拟一些代码,但它应该很容易; 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. AHK记录器应具有足够的功能,让您以点击方式创建它,而IIRC它足够智能,可以让您将此行为限制为仅限某个类的窗口。

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. 通知栏中只需一个图标。

Visual Studio 2008 defaults this to F12, but you can set it in Tools | Visual Studio 2008默认为F12,但您可以在Tools |中进行设置 Options | 选项| Environment | 环境| Keyboard, and change Edit.GoToDefinition - however, I'm not sure how you can get it to CTRL+mouseclick. 键盘,并更改Edit.GoToDefinition - 但是,我不知道如何将它转换为CTRL + mouseclick。

Just a quick note that the following AutoHotkey script works for me in Visual C++ 2010 Express. 请注意,以下AutoHotkey脚本在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. 我也将View.NavigateForward和View.NavigateBackward的快捷方式更改为Alt + Right / Left Arrow,因为我已经习惯了Eclipse。

Yes, both Resharper (a must have!) and Productivity Power Tools have this feature. 是的,Resharper(必须拥有!)和Productivity Power Tools都具有此功能。

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. 如果您只使用两个工具上的默认值(如果您安装了这两个工具),您可能会遇到频繁的双跳问题(从第一次点击的位置跳转到定义,然后再从第一次到达时跳到光标所在的位置定义)直到您关闭这些加载项的其中一个Ctrl-Click功能。

将鼠标光标放在方法名称或任何标识符上,然后按F12

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM