eclipse Visual Studio - 更改类时自动刷新类视图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/546113/
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
Visual Studio - Automatically refresh class view when changing class
提问by WillH
I come from a Java background and have spent many years using Eclipse. One feature that I miss when using Visual Studio (2008) is that the class view does not automatically refresh when I change class. In Eclipse it has a (class) 'Outline' window which represents the current class and shows methods/properties etc, this always updates to the class one is using.
我来自 Java 背景并且使用 Eclipse 已经很多年了。我在使用 Visual Studio (2008) 时错过的一项功能是,当我更改类时,类视图不会自动刷新。在 Eclipse 中,它有一个(类)“大纲”窗口,它代表当前类并显示方法/属性等,这总是更新到正在使用的类。
The equivalent 'Class View' in VS does not automatically refresh according to the current class I am visiting. I wondered if anyone knew a way to make this happen?
VS 中等效的“类视图”不会根据我正在访问的当前类自动刷新。我想知道是否有人知道实现这一目标的方法?
Ideally I'd like the VS view to be as similar to Eclipse as I could get it, but this one feature would be great.
理想情况下,我希望 VS 视图与 Eclipse 尽可能相似,但这一功能会很棒。
Thanks in advance, Will
提前致谢,威尔
回答by
After reading kingmaxxx's reply, I went to Tools->Options->Environment->Keyboard and bound Ctrl+Shift+C to View.SynchronizeClassView in Text Editor view. This seems to supplant and supplement the original behavior (View.ClassView), as it will display ClassView if it wasn't visible and focus on the current class.
阅读kingmaxxx的回复后,我去工具->选项->环境->键盘并在文本编辑器视图中将Ctrl+Shift+C绑定到View.SynchronizeClassView。这似乎取代并补充了原始行为 (View.ClassView),因为如果 ClassView 不可见,它将显示 ClassView 并专注于当前类。
(Visual Studio 2008)
(Visual Studio 2008)
回答by WillH
For Visual Studio 2005
对于 Visual Studio 2005
I found a solution that does not update the view automatically, but at least you get a context entry that helps:
我找到了一个不会自动更新视图的解决方案,但至少您会获得一个有助于以下内容的上下文条目:
http://blogs.msdn.com/ansonh/archive/2005/12/09/502020.aspx
http://blogs.msdn.com/ansonh/archive/2005/12/09/502020.aspx
You can also define a shortcut key:
您还可以定义快捷键:
Tools->Options->Environment->Keyboard and see if you can find "View.SynchronizeClassView".
工具->选项->环境->键盘,看看能不能找到“View.SynchronizeClassView”。
Oh, just for laughs - here is the answer of Microsoft: http://msdn.microsoft.com/en-us/library/2dae8h2s.aspx
哦,只是为了笑 - 这是微软的答案:http: //msdn.microsoft.com/en-us/library/2dae8h2s.aspx
...you can select any symbol in the Code Editor and locate it instantly...
...您可以在代码编辑器中选择任何符号并立即找到它...
After 7 Steps...
经过7 个步骤...
"Class View automaticallyscrolls to the location of the selected symbol in its hierarchy. "
“类视图会自动滚动到其层次结构中所选符号的位置。”
回答by tanascius
I can't help you with the class view, but maybe you want to give the solution explorer a try? You can synchronize this one via:
我无法在类视图方面为您提供帮助,但也许您想尝试一下解决方案资源管理器?您可以通过以下方式同步这个:
tools -> options -> projects and solutions -> general
enable "track active item in solution explorer"
回答by Jarek Mitek
The best way is to create a context menu when you right-click on a type in code editor. Tools->Customize Click on 'Commands' tab. Select Context Menu radio button, and select "Editor Context Menus | Code Window". Then "Add Command" and select View->Synchronize Class View.
最好的方法是在代码编辑器中右键单击类型时创建上下文菜单。工具-> 自定义 单击“命令”选项卡。选择上下文菜单单选按钮,然后选择“编辑器上下文菜单|代码窗口”。然后“添加命令”并选择“视图”->“同步类视图”。
Now whenever you right-click on a type, you can select "Synchronize Class View". It's the very top context-menu item.
Looks like this:
现在,无论何时右键单击类型,都可以选择“同步类视图”。它是最顶层的上下文菜单项。看起来像这样:
回答by Nicholas
The problem with View.SynchronizeClassView is that is doesn't work when a class is being viewed from a virtual folder.
View.SynchronizeClassView 的问题是当从虚拟文件夹查看类时它不起作用。
回答by Nicholas
based on kingmaxxx's response I found that you can add a button to your toolbar to do the same:
根据 kingmaxxx 的回复,我发现您可以在工具栏中添加一个按钮来执行相同的操作:
Tools|Customize -> Commands[tab] -> View[Categories]
工具|自定义 -> 命令[选项卡] -> 查看[类别]
Grab the Synchronize Class View button and drag it to one of your toolbars.
抓住同步类视图按钮并将其拖到您的工具栏之一。
回答by fakeleft
回答by Jakob Christensen
I don't know of any ways to do this but I agree that it would be a nice feature.
我不知道有什么方法可以做到这一点,但我同意这将是一个不错的功能。
You can track items in Solution Explorer though (Options->Project and Solutions->General->Track Active Item in Solution Explorer).
您可以在解决方案资源管理器中跟踪项目(选项->项目和解决方案->常规->在解决方案资源管理器中跟踪活动项目)。
回答by Lucas Naldi
Also coming from java (Eclipse), I missed the outline (Class viewer). I have tried many solutions and the best I found is to use the CODEMAID extension.
同样来自java(Eclipse),我错过了大纲(类查看器)。我尝试了很多解决方案,我发现最好的方法是使用CODEMAID 扩展名。
It also provides a lot of other tool but you are free not to use it!
它还提供了很多其他工具,但您可以自由地不使用它!
回答by rmirabelle
For Visual Studio 2017, CodeMaid Spade comes to the rescue quite perfectly.
对于 Visual Studio 2017,CodeMaid Spade 非常完美地解决了这个问题。
https://marketplace.visualstudio.com/items?itemName=SteveCadwallader.CodeMaid
https://marketplace.visualstudio.com/items?itemName=SteveCadwallader.CodeMaid
At first, I couldn't find the equivalent to 'Class View'. It's called Spade.
起初,我找不到相当于“类视图”的东西。它叫做锹。
It auto-syncs to the currently open class.
它会自动同步到当前打开的课程。