How to show code outline in Visual Studio?

Viewed 88240

This kind of stuff exists in Eclipse:

alt text

But I've not found it in Visual Studio yet. Is there such a window to show code outline at all?

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?

20 Answers

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.

1) View -> Open View

enter image description here

2) select (or type) Outline

enter image description here

3) You'll now get an Outline palette that shows full information on the class including properties and functions.

enter image description here

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:

#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.

Outline

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.

VS10x Code Map v2

Screenshot:

Screenshot of the code map

In VS2017 you can navigate between items in the file directly from the upper right corner of the Editor.

Screenshot

If you use PHP, make sure you install full version as mentioned in the docs

Here's how to add a command to one of the toolbars in Visual Studio (or how I know how to do it, anyway):

1.) Click the little down arrow at the end of the toolbar, select "Add or Remove Buttons", then select "Customize..."

Customize toolbar

2.) Now click the "Add Command..." button on the right.

3.) Click "Edit" in the left scroll list and then scroll down on the right until you see the two "Outline Toggle" commands:

Outline Toggle commands

4.) Choose one (I'll choose "Outline Toggle All" to toggle outlining in the entire open document) and click "OK."

5.) Now that command will be apart of the toolbar who you first clicked "Add/Remove Buttons" to. You can re-order the command to put it in different positions in the toolbar. Here's an example where I've added it to the main toolbar that has your typical Save/Undo/Debug commands:

Outline Toggle button added to toolbar

A list of things you can use:
1.Visual Studio default's ClassView
2.Visual Assist's VA OUTLINE Feature
3.CodeMaid's Spade Feature

Related