Visual Studio is a popular integrated development environment (IDE) from Microsoft that offers a host of tools to make software developers’ lives easier when writing, debugging, and deploying code. This guide will reveal some of the top Visual Studio tips and tricks you can implement to make the most of the IDE’s long list of productivity and efficiency-boosting features.
Visual Studio Tips and Tricks
The following Visual Studio tips can help you increase productivity and save time writing code, whether you are a beginner or a more experienced user of Microsoft’s IDE.
- Enjoy a More Familiar Layout
- Code Quickly With IntelliSense
- Save Time With Code Snippets
- Skip Copy/Paste When Duplicating Code
- Easily Copy Code To Other Programs
- Fix Code With Quick Actions
- Perform a Quick Search
- Set Code Bookmarks
- Save Time When Debugging
- Debug Collaboratively With Live Share
- Only Display Essential Errors
- Uncover Code Changes Without Leaving the Editor
- Use Code Maps To Better Understand Your Code
- Accelerate Development With Sample Applications
A More Familiar Layout
An intuitive interface is essential for seamless navigation and optimal productivity. If you prefer to have Visual Studio’s Properties window on the right-hand side of your display, you can easily move it by pressing F4.
Code Quickly With IntelliSense
IntelliSense is a real-time code completion feature in Visual Studio that can increase your coding efficiency, accuracy, and speed. When entering code in the editor, IntelliSense information (Parameter Info, List Members, Quick Info, Complete Word) will appear, displaying multiple features that support fuzzy text matching. When viewing results for List Members, for example, you will see entries containing the character combination you typed not just at the start but also anywhere in their names.
You can switch IntelliSense to suggestion mode if you want more control over the process when entering code. This ensures that only explicitly chosen IntelliSense options are inserted. You can enable suggestion mode via the menu bar by clicking Edit, IntelliSense, and Toggle Completion Mode. You can also enable it by pressing the Ctrl, Alt, and Spacebar keys.
Save Time With Code Snippets
A code snippet is a small block of reusable code that you can easily insert to increase coding speed and consistency while promoting standardization and reducing repetitive tasks. Visual Studio lets you create your own snippets for customization or use built-in ones for convenience. You can insert snippets into a code file using the keyboard shortcut of Ctrl+K, Ctrl+X. You can also do it via the context or right-click menu in the code editor by selecting Snippet followed by Insert Snippet. Lastly, you can go to the menu bar and select Edit, IntelliSense, and Insert Snippet.
Skip Copy/Paste When Duplicating Code
Visual Studio is loaded with convenience commands to speed up your code editing. Instead of copying a line, moving your cursor, and pasting it just to duplicate code, do the following: Select Edit followed by Duplicate. Or, if you prefer shortcuts, you can simply type Ctrl+E, V to duplicate the code without having to execute the clunky copy/paste process.
In continuing with the convenience theme, you can also expand/contract a text selection using the following commands: Select Edit, Advanced, Expand Selection or Edit, Advanced, Contract Selection. And, if you prefer keyboard shortcuts, you can type Shift+Alt+= to expand or Shift+Alt+- to contract.
Easily Copy Code To Other Programs
Having to manually fix code indentation after pasting it can be a messy and time-consuming process. With its new copy and trim indentation feature, Visual Studio automatically fixes indentation when you copy and paste code from the IDE to another application, such as Microsoft Teams, Outlook, etc. You will need Visual Studio 2022 version 17.7 or later to enjoy this time-saving trick.
Fix Code With Quick Actions
Visual Studio’s Quick Actions offer quick fixes that let you perform various functions through a single, streamlined action. If the code analyzer detects a rule violation, you can use Quick Actions to fix the code. Or, if you prefer, you can also use Quick Actions to configure the rule violation’s severity or suppress it altogether. You can also use Quick Actions to generate code or refactor.
Visual Studio icons will appear when a Quick Action is available. If Quick Actions are available for changing your code that are not 100% necessary or should be applied, the screwdriver icon will appear. On the flip side, if Quick Actions are available that should be implemented to improve your code, the yellow lightbulb icon will appear. And if there are Quick Actions available for fixing a code error, the yellow lightbulb icon with a red X will appear.
You can apply Quick Actions via the aforementioned icons. You can also apply them, if available, by moving your cursor over a line of code and pressing Ctrl+. It is worth noting that some Quick Actions are language-specific, and this feature is available for Visual Basic, C#, and C++ code files.
Perform a Quick Search
Use the Ctrl+Q shortcut to bring up the search box quickly. From there, you can enter specific keywords or phrases to find menu commands, dialog boxes, options, and more.
Set Code Bookmarks
We have shared multiple Visual Studio tips to help you write code quicker, which is one way to boost your development productivity. But what about navigating your code quicker? That is another way to boost productivity, and bookmarks are one way to achieve that goal.
Getting to specific locations in your code can take a long time if you are working on a large project. Set bookmarks for lines of code, and you will no longer have that time-consuming problem, as you will be able to instantly get where you need to or even jump between locations with ease.
Visual Studio bookmarks are accessible via the Bookmarks toolbar or the Bookmarks window. You can access the Bookmarks window using the keyboard shortcut (Ctrl+K, Ctrl+W) or by going to the menu bar and selecting View followed by Bookmark Window.
You can add a bookmark by placing the cursor on the desired line of code and selecting Toggle a bookmark. This will place a bookmark icon next to the line. You can also rename, disable, or delete bookmarks, plus quickly navigate between them using the bookmark window’s Next and Previous buttons.
Save Time When Debugging
Visual Studio has robust debugger tools to spot errors, identify their root causes, and ensure that the code behaves as intended. A great way to save time when debugging is to move the execution point from its current location to a different section of code you want to debug. You can then restart debugging (focusing on that specific piece of code) without the need to replicate all the time-consuming steps necessary to reach that particular section.
Debug Collaboratively With Live Share
Visual Studio Live Share is a collaborative feature that lets you edit and debug with other developers in real-time. Best of all, Live Share is accessible regardless of the app types you are working on or the programming languages you are using.
Live Share differs from traditional pair programming by letting developers work together using their own cursor and preferred editor preferences, such as theme and keybindings. By letting developers work together while keeping their personal preferences, Live Share offers an experience that mimics in-person collaboration. Live Share lets you share terminal instances, start joint debugging sessions, share current projects, make voice calls, and more securely.
Only Display Essential Errors
Seeing a visual overload of errors in your Error List window can be distracting and make it tough to focus. Luckily, you can filter the errors that appear to your liking, so you only have to focus on the most essential fixes.
Go to the Error List toolbar and select the Filter button. From there, you can choose to display just the errors in the current project, the current file, or the ones that are open in the editor. If necessary, you can also find specific errors by performing a search in the Error List window.
Uncover Code Changes Without Leaving the Editor
CodeLens is a focus-boosting Visual Studio feature that lets you see code changes and other history without leaving the editor. Available even in the free Visual Studio Community Edition, CodeLens lets you find references to your code. It also lets you inspect code history to see what happened to your code. It allows you to review changes prior to merges to understand how other branch changes could affect your code and determine who changed your code (and what changes were made), when your code was branched or changes got merged, what the incoming changes are, and other information such as linked work items/code reviews/bugs, associate unit tests, and more. You can access CodeLens by navigating to Tools, Options, Text Editor, All Languages, and CodeLens.
Use Code Maps To Better Understand Your Code
Instead of sifting through tons of files and lines of code, you can better understand your code structure and how everything fits together by using code maps. This Visual Studio feature offers a visual breakdown of your code’s relationships, structure, dependencies, and overall organization. Code maps also offer insight into how to update your code and, perhaps, more importantly, what it will cost to make any changes.
Accelerate Development With Sample Applications
The Visual Studio tips and tricks listed above can help streamline your development workflow, increase your productivity, and leverage the power of the popular IDE’s many robust capabilities. Once you become comfortable implementing these tips into your regular coding routine, look for others to sharpen your Visual Studio and development skill set even more.