Navigate and Edit
The navigation and editing tools described in this overview are enabled by theC# Dev Kit extension, a lightweight extension to enhance your C# development experience in Visual Studio Code.
Code Navigation
With theOutline view, you can conveniently navigate the members within the current file. Installing the C# Dev Kit extension also gives you theSolution Explorer view. This view helps you add, manage, and modify your projects contained within a larger solution without switching between the command line and the editor.
Go To Definition
TheGo To Definition feature navigates to the source or file of a type or member, and opens the result in a new tab. If you are a keyboard user, place your text cursor somewhere inside the symbol name and pressF12. If you are a mouse user, either right-click the symbol name and selectGo To Definition from the context menu orCtrl+click the symbol name. You can also useCtrl+Alt+click to open the definition on the side.
Peek Definition
You can take a quick look at how a symbol was defined by using thePeek Definition feature. This feature displays a few lines of code near the definition inside a peek window, so you can take a look without navigating away from your current location.
To peek at a symbol's definition, place your cursor on the symbol anywhere it's used in your source code and then press⌥F12 (WindowsAlt+F12, LinuxCtrl+Shift+F10). Alternatively, you can choosePeek Definition from the context menu (right-click, then choosePeek > Peek Definition).
Peek Implementations
You can take a quick, inline view at how and where a class, method, or symbol was implemented using thePeek Implementations feature.
To view the list of implementation locations, place the cursor on the symbol anywhere it's used in your source code and then press⇧⌘F12 (Windows, LinuxCtrl+Shift+F12). Alternatively, you can choosePeek Implementations from the context menu (right-click, then choosePeek > Peek Implementations).
Peek References
You can get an inline list of sources where a selected symbol has been referenced in your code using thePeek References feature. Place the cursor on the symbol anywhere it's used in your source code, right-click, then choosePeek > Peek References.
Collapse or expand code snippets
To better view the source code, hover over the editor gutter to collapse or expand code snippets using the caret that appears.
Smart selection
Withsmart selection (semantic selection), you can expand or shrink the selection range based on the semantic information of the caret position in your source code.
- To expand the selection, use⌃⇧⌘→ (Windows, LinuxShift+Alt+Right)
- To shrink the selection, use⌃⇧⌘← (Windows, LinuxShift+Alt+Left)
Inlay hints
Inlay hints are subtle annotations that appear inline in your code to provide additional context about your code elements. In C#, these hints can show parameter names at call sites, type information for variables, and other helpful details that make your code more readable without having to navigate to the definition. These hints can be particularly helpful when working with methods that have multiple parameters or when type inference makes it less obvious what type a variable is.
To change which inlay hints you want to enable or disable, view thecsharp.inlayHints settings.