visual-studio 在 Visual Studio 2008 中,如何让 control+click 执行“转到定义”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/80857/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
In Visual Studio 2008, how can I make control+click do a "Go To Definition"?
提问by Blorgbeard is out
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".
在 Delphi IDE 中,您可以按住控件并单击一个方法以跳转到其定义。在 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+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?
我不认为有办法让它在基础 VS2008 中工作 - 我错了吗?或者也许有一个我可以使用的插件?
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.
编辑:单击然后 F12 确实有效 - 但对我来说并不是一个好的解决方案..它仍然比 ctrl+click 慢。我可能会尝试 AutoHotkey,因为我已经在运行它了。
Edit: AutoHotkeyworked for me. Here's my script:
编辑:AutoHotkey对我来说有效。这是我的脚本:
SetTitleMatchMode RegEx
#IfWinActive, .* - Microsoft Visual Studio
^LButton::Send {click}{f12}
采纳答案by badp
You could create an Autohotkey script that does that. When you ctrl-click a word, send a doubleclick then a F12.
您可以创建一个 Autohotkey 脚本来执行此操作。当您按住 ctrl 单击一个单词时,发送双击,然后发送 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.
我手边没有 AHK,所以我无法尝试绘制一些代码,但这应该很容易;AHK 记录器应该具有足够的功能,让您以“n”点击方式创建它,而 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.
准备好脚本后,只需在编写代码时在后台运行脚本即可。它只需要通知栏中的一个图标。
回答by splintor
Not for Visual Studio 2008, but if you upgrade to Visual Studio 2010, you can use the free Visual Studio 2010 Pro Power Toolsfrom Microsoft to achieve this.
不适用于 Visual Studio 2008,但如果升级到 Visual Studio 2010,则可以使用Microsoft 提供的免费 Visual Studio 2010 Pro Power Tools来实现此目的。
回答by Raithlin
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.
Visual Studio 2008 默认为 F12,但您可以在工具 | 中设置它。选项 | 环境 | 键盘,并更改 Edit.GoToDefinition - 但是,我不确定如何将其设置为 CTRL+mouseclick。
回答by Catalin DICU
Resharperdoes that but it's not free. Highly recommended plugin though, most experienced .NET developers use it.
Resharper 会这样做,但它不是免费的。虽然强烈推荐插件,但大多数有经验的 .NET 开发人员都会使用它。
回答by Tianhao Qiu
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.
由于我习惯了 Eclipse,我还将 View.NavigateForward 和 View.NavigateBackward 的快捷方式更改为 Alt+Right/Left Arrow。
回答by doogie
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 功能之一。
回答by RWendi
Put the mouse cursor on the method name or any identifier, and press F12
将鼠标光标放在方法名称或任何标识符上,然后按 F12

