Eclipse 的 Ctrl+单击在 Visual Studio 中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/168369/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:27:15  来源:igfitidea点击:

Eclipse's Ctrl+click in Visual Studio?

visual-studioeclipsekeyboard-shortcutsusability

提问by shoosh

After working for a few days with Eclipse Java I totally got addicted to pressing Ctrland 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.

在使用 Eclipse Java 工作了几天之后,我完全沉迷于按下Ctrl并单击标识符以转到其定义。从那时起,我一直在寻找一种在 Visual Studio 中实现这一目标的方法。

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

我意识到 VS 有右键单击,转到定义,这F12也是一样的。我也意识到 Visual Assist 对Alt+做了类似的事情G。然而,这些都没有Ctrl+ 点击那么完美。

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.

我实际上已经尝试了几个小时的运气,试图编写一个 VS 插件来做到这一点,但在我认为合理的时间范围内没有取得任何进展。

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

有谁知道这是如何实现的?一个准备好的插件?某种宏?

回答by splintor

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

如果您使用 Visual Studio 2010,则可以使用Microsoft 提供的免费 Visual Studio 2010 Productivity Power Tools来实现此目的。

回答by Se Song

I use visual studio 2013 and 2015, I installed Go To Definition. To install this extension navigate on TOOLS-> Extensions and Updates.

我使用 Visual Studio 2013 和 2015,我安装了Go To Definition. 要安装此扩展程序,请导航至TOOLS-> Extensions and Updates

enter image description here

在此处输入图片说明

回答by Joel Coehoorn

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

我会回答那些询问Ctrl-click 和F12.

Ctrl-click workflow:

Ctrl- 单击工作流程:

  • Move hand to mouse
  • Move mouse to hover over variable name
  • Other hand holds down Ctrlkey while you click
  • Move mouse to position cursor, highlight, right-click, or whatever
  • Move hand back to keyboard to continue typing
  • 将手移到鼠标
  • 移动鼠标悬停在变量名称上
  • Ctrl单击时另一只手按住键
  • 移动鼠标以定位光标、突出显示、右键单击或其他任何方式
  • 将手移回键盘以继续打字

F12workflow

F12工作流程

  • Move hand to mouse
  • Mouse mouse to hover over variable name
  • Move hand back to keyboard
  • Hit F12key
  • Move hand back to mouse
  • Move mouse to position cursor, highlight, right-click, or whatever
  • Move hand back to keyboard to continue typing
  • 将手移到鼠标
  • 鼠标将鼠标悬停在变量名称上
  • 将手移回键盘
  • 命中F12关键
  • 将手移回鼠标
  • 移动鼠标以定位光标、突出显示、右键单击或其他任何方式
  • 将手移回键盘以继续打字

If you assume the cursor is already positioned on the desired variable, F12is 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.

如果您假设光标已经定位在所需的变量上,F12那就更好了。然而,这种情况很少发生。此外,如果您在此特定操作后停止,假设您想把手放回键盘,成本是相同的。但是,如果您记住,您可能有想要转到定义的理由,则Ctrl-click 工作流为您节省了在键盘和鼠标之间移动的实例。

回答by sean e

Visual Assistsupports Ctrl+Click as of June 2009 (build 1727). Activate Ctrl+LeftClick in VA Options | Advanced | General. (See the comment below.)

Ctrl2009 年 6 月起,Visual Assist支持+Click(内部版本 1727)。Ctrl在 VA 选项中激活+LeftClick | 高级 | 一般的。(请参阅下面的评论。)

回答by mhenry1384

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

如果您有 Visual Studio 2010,您可以使用 Noah Richards 的“Go To Definition”。

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

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

回答by Diego

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

哦,伙计,只需安装 resharper !!(vs 插件)安装它后,您只需Ctrl点击 + 单击即可转到定义。

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

这不是 resharper 所做的唯一事情,请免费试用!!!

回答by Danny Tuppeny

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.

我使用内置选项(F12,右键单击 -> 转到定义),但我知道我公司的很多人都在使用 Resharper,它确实具有此功能。

回答by Danny Tuppeny

Microsoft released a Visual Studio 2010 extension named "Productivity Power Tools" which now adds Ctrl+Click functionality. So if you're like me, and hate installing third-party addons, you can now have the same functionality!

Microsoft 发布了一个名为“ Productivity Power Tools”的 Visual Studio 2010 扩展,它现在添加了Ctrl+Click 功能。因此,如果您像我一样讨厌安装第三方插件,现在您可以拥有相同的功能!

回答by Justin R.

Another option with VS (besides F12and 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.

VS 的另一个选项(除了F12右键单击 > 转到定义)是添加代码定义窗格(查看 > 代码定义窗口)。这本质上是另一个显示当前符号代码的编辑窗格 - 无需Ctrl单击或任何操作。我把它固定在我的辅助显示器上。每当我需要查看符号的实现时,我只需单击它并查看即可。

Another nice thing about F12is you can also do ShiftF12to find references to a symbol and F8through them. The two go together like love and happiness.

另一个好处F12是您还ShiftF12可以查找对符号的引用并F8通过它们。两人像爱情和幸福一样走到了一起。

回答by Marty Dill

I prefer to bind Go To Definition to CtrlD. This makes it extremely easy to use either with both hands on the keyboard (CtrlDto go tho the definition of the symbol under the cursor) or one hand on the keyboard and one hand on the mouse (Click on a symbol, then CtrlD).

我更喜欢将 Go To Definition 绑定到CtrlD. 这使得使用双手在键盘上(CtrlD去光标下符号的定义)或一只手在键盘上,一只手在鼠标上(单击符号,然后CtrlD)非常容易。