visual-studio 如何在 Visual Studio 中显示代码大纲?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3793892/
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
How to show code outline in Visual Studio?
提问by Alan
This kind of stuff exists in Eclipse:
这种东西存在于 Eclipse 中:


But I've not found it in Visual Studio yet. Is there such a window to show code outline at all?
但我还没有在 Visual Studio 中找到它。有没有这样的窗口来显示代码大纲?
I tried both Document Outline and Class View windows. The Class View is close, but it only shows class information, can it come up with function info also?
我尝试了文档大纲和类视图窗口。Class View 很接近,但是它只显示类信息,它是否也能提供函数信息?
采纳答案by stijn
not free, but if you install Visual AssistX, each document gets a dropdown box listing all methods in a file (alphabetically or in the order they occur)
check Class View again, it does show functions (but not per document). Also check out the Code Definition Window, extremely nice when combined with Class View.
不是免费的,但如果您安装 Visual AssistX,每个文档都会有一个下拉框,列出文件中的所有方法(按字母顺序或出现顺序)
再次检查类视图,它确实显示了功能(但不是每个文档)。还可以查看代码定义窗口,与类视图结合使用时非常好。
回答by Sebastian
Also non-free, but Jetbrains Resharperprovides a File Structure Window, what perhaps is what you are searching for.
同样非免费,但Jetbrains Resharper提供了一个File Structure Window,这可能是您正在搜索的内容。
To display this dockable window, select from the menu: ReSharper → Windows → File Structure (default shortcut Ctrl+Alt+F
要显示此可停靠窗口,请从菜单中选择:ReSharper → Windows → 文件结构(默认快捷方式Ctrl+ Alt+F
回答by jiasli
回答by gomisha
This question was asked quite a while ago and before Visual Studio Code existed but I found it when searching for how to do this with Visual Studio Code so I thought others might stumble on this question too so I thought I'd share my solution. Here's how to do it in Visual Studio Code. I'm using TypeScript but it works for JavaScript, too.
这个问题很久以前就被问到了,在 Visual Studio Code 存在之前,但我在搜索如何使用 Visual Studio Code 执行此操作时发现了它,所以我认为其他人也可能会偶然发现这个问题,所以我想我会分享我的解决方案。以下是在 Visual Studio Code 中执行此操作的方法。我正在使用 TypeScript,但它也适用于 JavaScript。
1) View -> Open View
1) 查看 -> 打开查看
2) select (or type) Outline
2)选择(或输入)大纲
3) You'll now get an Outline palette that shows full information on the class including properties and functions.
3) 您现在将获得一个 Outline 调色板,其中显示有关该类的完整信息,包括属性和函数。
回答by Antiohia
In newer Visual Studio versions (e.g. 2015) you can see this directly in the solution explorer. Simply expand the .cs file and you will get the list of the methods in the order they are listed in the file. This is exactly the same as the Outline in Eclipse.
在较新的 Visual Studio 版本(例如 2015)中,您可以直接在解决方案资源管理器中看到这一点。只需展开 .cs 文件,您将按照文件中列出的顺序获得方法列表。这与 Eclipse 中的 Outline 完全相同。
If you want to see the stuff alphabetically, open the file and between the tab pane and the editor, there is a row showing the project name, the class name with namespace, and a drop down with the available methods and properties.
如果您想按字母顺序查看内容,请打开文件,在选项卡窗格和编辑器之间,有一行显示项目名称、带有命名空间的类名称以及带有可用方法和属性的下拉列表。
回答by Spoike
There is now a free add-in available through the add-in manager in VS2010 that works quite well. It also has a dark theme.
现在有一个免费的插件可以通过 VS2010 中的插件管理器使用,效果很好。它也有一个黑暗的主题。
Screenshot:
截屏:


回答by Ray
You can use the Class View Window, or you can use outlining to collapse the code window to definitions (Ctrl-M-O and Ctrl M-L in the standard keyboard set up)
您可以使用类视图窗口,也可以使用大纲将代码窗口折叠为定义(标准键盘设置中的 Ctrl-MO 和 Ctrl ML)
回答by Ciantic
Trick is to call Ctrl+F2, then Tab, then Tab, then Down arrow. I've done it with this simple AutoHotkey script when I hit Ctrl+o:
技巧是调用 Ctrl+F2,然后是 Tab,然后是 Tab,然后是向下箭头。当我按下 Ctrl+o 时,我已经用这个简单的 AutoHotkey 脚本完成了它:
#IfWinActive ahk_exe devenv.exe
^o::
Send ^{F2}
Send {Tab}
Send {Tab}
Send {Down}
return
#IfWinActive
It will show dropdown that is closest to Quick Outline in Eclipse or others.
它将显示最接近 Eclipse 或其他中的 Quick Outline 的下拉菜单。
回答by sbillah
回答by Daniele Diodati
In VS2017 you can navigate between items in the file directly from the upper right corner of the Editor.
在 VS2017 中,您可以直接从编辑器的右上角在文件中的项目之间导航。



