简体   繁体   English

Eclipse的Ctrl +在Visual Studio中单击?

[英]Eclipse's Ctrl+click in Visual Studio?

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. 在使用Eclipse Java工作了几天后,我完全沉迷于按Ctrl键并单击标识符以转到其定义。 Since then I've been looking for a way to achieve this in Visual Studio as well. 从那时起,我一直在寻找在Visual Studio中实现这一目标的方法。

I realize VS has right click, Go to definition, and that F12 does the same. 我意识到VS有右键单击,转到定义,而F12也是如此。 I also realize that Visual Assist does something similar with Alt + G . 我也意识到Visual Assist与Alt + G做了类似的事情。 Yet none of these are as perfect as Ctrl + click. 然而,这些都不如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? 一种宏?

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

I use visual studio 2013 and 2015, I installed Go To Definition . 我使用visual studio 2013和2015,我安装了Go To Definition To install this extension navigate on TOOLS -> Extensions and Updates . 要安装此扩展,请导航TOOLS - > Extensions and Updates

在此输入图像描述

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 Ctrl key while you click 单击时,另一只手按住Ctrl
  • Move mouse to position cursor, highlight, right-click, or whatever 将鼠标移动到光标位置,高亮显示,右键单击等等
  • Move hand back to keyboard to continue typing 将手移回键盘继续键入

F12 workflow F12工作流程

  • Move hand to mouse 将手移到鼠标
  • Mouse mouse to hover over variable name 鼠标鼠标悬停在变量名称上
  • Move hand back to keyboard 将手移回键盘
  • Hit F12 key 点击F12
  • 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. 如果假设光标已经定位在所需的变量上,则F12更好。 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. 但是如果你记住你可能有理由想要去定义, Ctrl -click工作流会为你节省一个在键盘和鼠标之间移动的实例。

Visual Assist supports Ctrl +Click as of June 2009 (build 1727). Visual Assist支持截至2009年6月的Ctrl + Click(版本1727)。 Activate Ctrl +LeftClick in VA Options | 在VA选项中激活Ctrl + LeftClick Advanced | 高级| General. 一般。 (See the comment below.) (见下面的评论。)

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

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

oh man, just install resharper!! 哦,伙计,只需安装resharper !! (vs plugin) with it installed you just go and Ctrl + click to go to definition. (vs插件)安装它你只需按住Ctrl键并单击进入定义。

this is not the only thing resharper does, try it out free!!! 这不是resharper唯一做的事情,免费试用!!!

Microsoft released a Visual Studio 2010 extension named " Productivity Power Tools " which now adds Ctrl +Click functionality. Microsoft发布了名为“ Productivity Power Tools ”的Visual Studio 2010扩展,现在添加了Ctrl + Click功能。 So if you're like me, and hate installing third-party addons, you can now have the same functionality! 因此,如果您像我一样,并且讨厌安装第三方插件,那么您现在可以拥有相同的功能!

Another option with VS (besides F12 and right-click > Go to Def) is add the code definition pane (View > Code Def Window). VS的另一个选项(除了F12并右键单击>转到Def)是添加代码定义窗格(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. 这实际上是另一个编辑窗格,显示当前符号的代码 - 无需Ctrl -click或任何其他内容。 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. 关于F12的另一个好处是你也可以使用Shift F12找到对符号的引用,并通过它们找到F8 The two go together like love and happiness. 这两个人像爱情和幸福一样走在一起。

All in all, both VS and Eclipse have weird key shortcuts. 总而言之,VS和Eclipse都有奇怪的密钥快捷方式。 I just had to respond, too: F12 is far too right on the keyboard and you have to leave the the mouse right hand for the keyboard to use it. 我也必须回应: F12在键盘上太右了,你必须让鼠标右手让键盘使用它。 As a long time VS user I just didn't find it until I searched for the Ctrl +Mouse equivalent in Eclipse. 作为很长一段时间的VS用户,我直到在Eclipse中搜索Ctrl + Mouse等效时才发现它。 It's completely borked. 它完全被塞住了。 OK? 好? No need to argue. 不用争论。 (The same goes for F3 in Eclipse going for definition. ???? Why the face??? It's FIND NEXT for Pete's sake. But this can be removed after mastering the Eclipse keyboard shortcut system in the course of a few years.) (对于Eclipse中的F3来说,定义也是如此。????为什么面孔?为了Pete的缘故,它会找到下一个。但是这可以在几年内掌握Eclipse键盘快捷键系统后删除。)

Anyway, as has been said here before, Microsoft has already understood this can be an issue for new programmers coming in from Eclipse, so they provided the Power Tools (I followed the link up above). 无论如何,正如之前所说,微软已经明白这可能是来自Eclipse的新程序员的一个问题,所以他们提供了Power Tools(我按照上面的链接)。

http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/ http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/

I prefer to bind Go To Definition to Ctrl D . 我更喜欢将Go To Definition绑定到Ctrl D. This makes it extremely easy to use either with both hands on the keyboard ( Ctrl D to 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 Ctrl D ). 这使得用双手放在键盘上非常容易( Ctrl D用于光标下方符号的定义)或单手操作键盘和单手鼠标(单击符号,然后按Ctrl D )。

如果您使用的是Visual Studio 2017,则可以使用Productivity Power Tools 2017

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. 我没有在VS工作,所以我没有使用它,但我听到了来自我认识的每个人的Resharper非常好的事情。 Everyone has told me it's worth every penny, and significantly improves efficiency in Visual Studio. 每个人都告诉我它值得每一分钱,并显着提高Visual Studio的效率。 I think it has a feature like what you're looking for, along with a TON of others. 我认为它有一个像你正在寻找的功能,以及其他人的TON。

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

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