Visual Studio 2017 C# productivity guide
Learn how Visual Studio 2017 makes developers more productive than ever. Take advantage of our performance and productivity improvements like navigation to decompiled assemblies, variable name suggestions as you type, a hierarchy-view in the Test Explorer, Go To All (Ctrl+T) to navigate to file/type/member/symbol declarations, an intelligent Exception Helper, code style configuration and enforcement, and many refactorings and code fixes.
I'm used to my keyboard shortcuts from a different extension/editor/IDE
New in Visual Studio 2017 version 15.8 If you're coming from another IDE or coding environment, you can change your keyboard scheme to Visual Studio Code or ReSharper (Visual Studio):
Some extensions also offer keyboard schemes:
The following are popular Visual Studio shortcuts:
|Shortcut (All Profiles)||Command||Description|
|Ctrl+T||Go To All||Navigate to any file/type/member/symbol declaration|
|F12 (also Ctrl+Click)||Go To Definition||Navigate to where a symbol is defined|
|Ctrl+F12||Go To Implementation||Navigate from a base type or member to its various implementations|
|Shift+F12||Find All References||See all symbol or literal references|
|Ctrl+. (also Alt+Enter in C# Profile)||Quick Actions and Refactorings||See what code fixes, code generation actions, refactorings, or other quick actions are available at your cursor position or code selection|
|Ctrl+D||Duplicate line||Duplicates the line of code that the cursor is in (available in Visual Studio 2017 version 15.6 and later)|
|Shift+Alt++/-||Expand/Contract selection||Expands or contracts the current selection in the editor (available in Visual Studio 2017 version 15.5 and later)|
|Shift + Alt + .||Insert Next Matching Caret||Adds a selection and caret at the next location that matches the current selection (available in Visual Studio 2017 version 15.8 and later)|
|Ctrl+Q||Quick Launch||Search all Visual Studio settings|
|F5||Start Debugging||Start debugging your application|
|Ctrl+F5||Run without Debug||Run your application locally without debugging|
|Ctrl+K,D (Default Profile) or Ctrl+E,D (C# Profile)||Format Document||Cleans up formatting violations in your file based on your newline, spacing, and indentation settings|
|Ctrl+\,Ctrl+E (Default Profile) or Ctrl+W,E (C# Profile)||View Error List||See all errors in your document, project, or solution|
|Alt + PgUp/PgDn||Go to Next/Previous Issue||Jump to the previous/next error, warning, suggestion in your document (available in Visual Studio 2017 version 15.8 and later)|
Some extensions unbind the default Visual Studio keybindings. To use the above commands, restore your keybindings to Visual Studio's defaults by going to Tools > Import and Export Settings > Reset all settings or Tools > Options > Keyboard > Reset.
Learn more keyboard shortcuts and commands in Visual Studio in our documentation.
I need a way to quickly navigate to files or types
Visual Studio 2017 has a feature called Go To All (Ctrl+T). Go To All enables you to quickly jump to any file, type, member, or symbol declaration.
- Change the location of this search bar or turn off the 'live navigation preview' with the gear icon.
- Filter results using our query syntax (for example, "t mytype"). You can also scope your search to just the current document.
- camelCase matching is supported!
My team enforces code style rules on our codebase
You can use an .editorconfig file to codify coding conventions and have them travel with your source.
- You can install the EditorConfig language services extension, which makes it easy to add and edit an .editorconfig file in Visual Studio.
- Try out the IntelliCode extension for Visual Studio. This experimental extension infers your code styles from existing code, and then creates a non-empty .editorconfig file with your code style preferences already defined.
- Check out the .NET coding convention options documentation.
- See this gist for an example .editorconfig file.
I need more refactorings and code fixes
Visual Studio 2017 comes with a lot of refactorings, code generation actions, and code fixes. Red squiggles represent errors, green squiggles represent warnings, and three gray dots represent code suggestions. You can access code fixes by clicking the light bulb or screwdriver icon, or by pressing Ctrl+. or Alt+Enter. Each fix comes with a preview window that shows a live code diff of how the fix works.
- Popular quick fixes and refactorings include:
- Extract Method
- Change Method Signature
- Generate Constructor
- Generate Method
- Move Type to File
- Add Null-Check
- Add Parameter
- Remove Unnecessary Usings
- Foreach Loop to LINQ Query or to LINQ method
- Pull Members Up Refactoring with Dialog Options
- See more in our documentation
- Write your own refactoring or code fix with Roslyn analyzers.
- Several community members have written free extensions which add additional code inspections:
I need Find Usages, Go To Implementation, Navigate To Decompiled Assemblies
Visual Studio 2017 has many features to help you search and navigate your codebase. Read more about Code navigation features
|Find All References||Shift+F12||Results are colorized and can be grouped by project, definition, and reference type such as read or write. You can also 'lock' results.|
|Go To Implementation||Ctrl+F12||You can use Go To Definition on the
|Go To Definition||F12 or Ctrl+Click||You can hold Ctrl while clicking to navgiate to definition|
|Peek Definition||Alt+F12||Inline view of a definition|
|Structure Visualizer||Gray, dotted-lines between braces||Hover to see your code structure|
|Navigation to decompiled assemblies||F12 or Ctrl+Click||Navigate to external source (decompiled with ILSpy) by enabling the feature: Tools > Options > Text Editor > C# > Advanced > Enable navigation to decompiled sources.|
I want to run and see my unit tests
We made a lot of improvements to the testing experience in Visual Studio 2017. Use either of our unit testing experiences with the MSTest v1, MSTest v2, NUnit, or XUnit test frameworks.
- Test Explorer test discovery is fast in version 15.6 (for best results, upgrade to the latest version of your test adapter).
- Organize your tests in Test Explorer with our new hierarchical sorting in version 15.6.
- Live unit testing continuously runs tests impacted by your code changes and updates inline editor icons to let you know the status of your tests. Include or exclude specific tests or test projects from your Live Test Set.
I want to debug my code
We've added a ton of new debugging capabilities in Visual Studio 2017:
- Run to click allows you to hover next to a line of code, hit the green 'play' icon that appears, and run your program until it reaches that line.
- The new Exception Helper puts the most important information, like which variable is 'null' in a NullReferenceException, at the top-level in the dialog.
- Step Back debugging enables you to go back to previous breakpoints or steps and view the state of the application as it was in the past.
- Snapshot debugging lets you investigate the state of a live web application at the moment an exception was thrown (must be on Azure).
I want to use version control with my projects
You can use git or TFVC to store and update your code in Visual Studio.
- Organize your local changes with Team Explorer and use the status bar to track pending commits and changes.
- Set up continuous integration and delivery for your projects inside of Visual Studio with our Continuous delivery tools for Visual Studio extension and adopt the agile developer workflow.
What other features do I need to know about?
Here is a list of editor and productivity features to make writing code more efficient. Some features may need to be enabled because they are off-by-default (they may index things on your machine, are controversial, or are currently experimental).
|Feature||Details||How to enable|
|Locate File in Solution Explorer||Highlights the active file in Solution Explorer||Tools > Options > Projects and Solutions > Track Active Item in Solution Explorer|
|Add usings for types in reference assemblies and NuGet packages||Shows an error light bulb with a code fix to install a NuGet package for an unreferenced type||Tools > Options > Text Editor > C# > Advanced > Suggest usings for types in reference assemblies and Suggest usings for types in NuGet packages|
|Enable full solution analysis||See all errors in your solution in the Error List||Tools > Options > Text Editor > C# > Advanced > Enable full solution analysis|
|Enable navigation to decompiled sources||Allow Go To Definition on types/members from external sources and use the ILSpy decompiler to show method bodies||Tools > Options > Text Editor > C# > Advanced > Enable navigation to decompiled sources|
|Completion/Suggestion Mode||Changes the completion behavior in IntelliSense--developers with IntelliJ backgrounds tend to change the setting here from the default||Menu > Edit > IntelliSense > Toggle Completion Mode|
|CodeLens||Displays code reference information and change history in the editor||Tools > Options > Text Editor > All Languages > CodeLens|
|Code snippets||Help stub out common boilerplate||Type a snippet name and press Tab twice.|
Missing a feature that makes you productive or experiencing poor performance?
There are several ways to leave us feedback:
- .NET feature requests can be filed on our GitHub repo.
- Visual Studio feature requests, bugs, and performance issues can be filed by using the Send Feedback icon at the top-right of your Visual Studio window.
We’d love to hear your thoughts. Choose the type you’d like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.