Visual Studio / VS Code Tips for C#
Learn Visual Studio and VS Code tips for C# to improve productivity with shortcuts, extensions, and efficient workflows.
Visual Studio and Visual Studio Code (VS Code) are two of the most powerful and widely used IDEs among C# developers. These tools not only facilitate writing code but also simplify debugging, auto-completion, testing, version control, and refactoring. Below is a compilation of the most useful tips, shortcuts, and settings to enhance productivity in these environments.
Visual Studio – General Tips
- Quick Search: Use Ctrl + Q to quickly search through menus, settings, and commands.
- Solution Explorer: Open Solution Explorer with Ctrl + Alt + L.
- Format Code: Automatically format the entire code using Ctrl + K + D or Ctrl + E + D.
- Go to Definition: Press F12 to navigate to a method or class definition.
- Quick Info: Hover over a variable or press Ctrl + K + I to view its type and description.
Debugging Shortcuts
Visual Studio has powerful debugging capabilities; using the right shortcuts can significantly reduce debugging time.
- F5 → Run or continue execution
- F10 → Step over (execute the current line without entering functions)
- F11 → Step into a method
- Shift + F11 → Step out of the current method
- Ctrl + Shift + F9 → Clear all breakpoints
- Ctrl + Alt + P → Attach the debugger to a running process
Code Navigation
- Ctrl + , → Quick search inside the code (find everything)
- Ctrl + T → Find a file or class quickly
- Ctrl + Tab → Switch between open files
- Ctrl + M + O → Collapse all methods
- Ctrl + M + L → Expand all methods
These features make navigating large projects much easier. Especially Ctrl + , is very handy for searching both methods and files.
Refactoring (Code Restructuring)
Visual Studio supports Refactoring operations to improve code quality.
- Ctrl + . → Opens the Quick Actions menu.
- Select a method or variable name and press Ctrl + R + R to rename.
- Ctrl + R + M → Extracts selected code into a new method.
- Click the “light bulb 💡” icon to see suggested refactoring actions.
Visual Studio Code – Developer Tips
VS Code is a lightweight yet highly extensible editor. For C# support, use the C# Dev Kit or OmniSharp extensions.
- Run Code: Ctrl + F5 to run quickly, F5 to start in debug mode.
- Open Terminal: Ctrl + ` (backtick) opens the integrated terminal.
- Quick File Search: Ctrl + P → Type the filename to open it directly.
- Go to Line: Ctrl + G → Jump to a specific line number.
- Duplicate Line: Shift + Alt + ↓ or ↑.
VS Code Extensions
The power of VS Code lies in its extensibility. The following extensions are recommended to boost productivity in C# projects:
- C# Dev Kit – Official Microsoft extension with IntelliSense and debugger support.
- NuGet Package Manager – Manage NuGet dependencies directly within VS Code.
- Roslyn Analyzer – Provides real-time code analysis and suggestions.
- GitLens – Displays line-by-line commit history.
- Bracket Pair Colorizer 2 – Improves readability with colored matching brackets.
Themes and Editor Customization
Choosing the right theme helps reduce eye strain during long coding sessions. In VS Code, you can change the theme with Ctrl + K + T.
- One Dark Pro – A popular dark theme inspired by Atom.
- Monokai Pro – Modern look with high-contrast colors.
- Night Owl – Eye-friendly theme for night use.
- GitHub Light Theme – A clean option for those who prefer light themes.
Recommended fonts: Cascadia Code or JetBrains Mono – both provide ligature support for a clean look.
Git and Version Control
Both Visual Studio and VS Code provide built-in Git integration. In VS Code, access it via the Source Control icon (branch icon) or Ctrl + Shift + G.
- Ctrl + Shift + P → Run “Git: Commit” or “Git: Push” commands.
- Alt + ↑ / ↓ → Move line up or down.
- Ctrl + K + Z → Zen mode (distraction-free view).
In Visual Studio, use the “Team Explorer” panel to easily perform commit, push, or merge operations.
Live Code Analysis (Code Analysis & Linter)
You can enable Roslyn-based analyzers to detect issues before compiling.
- Create an EditorConfig file:
[*.cs]
dotnet_diagnostic.CA1822.severity = suggestion
dotnet_diagnostic.CA1303.severity = warning
This file defines your coding standards. Both VS Code and Visual Studio automatically apply these rules.
Performance and Memory Profilers
In Visual Studio, the Diagnostics Tools window (Ctrl + Alt + F2) allows you to analyze CPU usage, memory consumption, and GC events. This tool is particularly useful for identifying performance bottlenecks.
// Access from the menu:
// Debug → Performance Profiler → Memory Usage / CPU Usage
Real-World Example: Using VS Code + .NET CLI
The following example demonstrates how to create and debug a simple C# project using only VS Code and the .NET CLI.
// Create a new project
dotnet new console -n SampleProject
cd SampleProject
// Open in VS Code
code .
// Debug configuration will be generated automatically (launch.json)
// Program.cs
using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello, VS Code Debugging!");
}
}
Press F5 to start debugging. The OmniSharp debugger will activate, and the program will run. Breakpoints, Watch panel, and Call Stack tools are available in VS Code just like in Visual Studio.
Best Practices
- Learn the keyboard shortcuts – reducing mouse usage increases productivity.
- Install only the necessary extensions; too many can slow down the editor.
- Choose a color theme and font that fit your visual comfort.
- In VS Code, back up your personal settings from settings.json.
- Use the “Live Share” feature in Visual Studio for real-time remote collaboration.
TL;DR
- Visual Studio – A full-featured IDE with deep debugging, profiling, and refactoring tools.
- VS Code – Lightweight, fast, and extensible editor.
- Shortcuts like Ctrl + K + D, F12, and Ctrl + , boost productivity.
- Use the Ctrl + . menu for refactoring actions.
- OmniSharp / C# Dev Kit are essential for C# in VS Code.
- Use “Diagnostics Tools” for performance analysis.
- Use
.editorconfigand Roslyn analyzers to maintain code quality.
Related Articles
Debugging Techniques in C#
Learn debugging techniques in C# using breakpoints, watch windows, and step tools to quickly identify and fix issues.
The Concept of Source Generators in C# (C# 9+)
Learn source generators in C# to generate code at compile time and improve performance with modern development techniques.
Writing Unit Tests in C# (xUnit, NUnit, MSTest)
Learn how to write unit tests in C# using xUnit, NUnit, and MSTest to build reliable and maintainable applications.