Last updated: Apr 6, 2024
Reading time·4 min
There are multiple ways to show a function and method list in VS Code.
You can show the list in Explorer (the left sidebar) or directly in your file.
To list the functions and methods in VS Code:
Ctrl
+ Shift
+ O
(the letter o
, not
zero).CMD
+ Shift
+ O
(the letter o
, not zero).You can view the key combination for the different operating systems in this table in the docs. The command is called Go to Symbol....
You can use the arrow keys to navigate and the Enter
key to move your cursor
to a specific function or method.
The menu also lists class methods if you have any classes in the file.
You can type :
(a colon) after pressing Ctrl
+ Shift
+ O
(or Cmd
+
Shift
+ O
on macOS) if you want to group the symbols in categories (e.g.
methods, functions, classes and variables).
You can also issue the command via the Command Palette:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.You can also issue the command directly:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.@
.The command lists the functions and methods in the file.
If you want to list the functions and methods in the entire workspace:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.Type #
.
Start typing to filter for specific functions or methods.
There is also a keyboard shortcut for the Show All Symbols command:
Ctrl
+ T
Cmd
+ T
If you need to change the keyboard shortcuts of the Go to Symbol in Editor or the Go to Symbol in Workspace commands:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.Enter
to confirm.If you need to show a function/method list in the left sidebar (Explorer) in VS Code:
The Outline view is located right below the list of files in Explorer (the left sidebar).
If explorer is not shown, press Ctrl
+ B
(or Cmd
+ B
on macOS) to toggle
it.
Once you expand the outline tab, you will be able to see the list of functions and methods for the currently opened file.
Notice that the methods are indented under the Employee
class.
NOTE: you can double-click on the functions or methods in the outline view to move your cursor to the given method in the file.
You can click on the three dots that appear when you hover over the outline tab to display sorting options.
When the Follow Cursor setting is enabled, the function or method that is selected in the file gets highlighted in the outline view in the sidebar.
You can sort the functions and methods by their position in the file, by their name or type.
Note that errors and warnings are also displayed in the Outline view.
I've also written an article on how to view the local history & restore previous file versions in VS Code.
You can learn more about the related topics by checking out the following tutorials: