If you are a user of Visual Studio 2022, you will know that it is an IDE that ships lots of useful features. While the majority of the day-to-day features are pretty easy to pick up, there are definitely a bunch of really useful features that I'm confident that you will be unaware of that will make your code-writing experiences quicker and simpler!

This is why the focus of this article is on the lesser-known features that are hidden within Visual Studio. This article will take you less than 10 minutes to read and could save you from making potentially hundreds of thousands of unneeded keystrokes. If that sounds good to you, read on

1. Inline Errors

The first tip might make it quicker for you to debug. Within Visual Studio it's possible to see errors within the IDE as inline messages. This feature resembles the capabilities offered by Visual Studio Show Inline Errors, however, it works out the box without you needing to turn anything on.

By default, this feature is turned off. In order to enable it, you will need to enable this setting:

ToolsOptionsText EditorC#AdvancedDisplay diagnostics inline (experimental)

After you enable this, you will see all errors inline:

Visual Studio 2022 Inline Errors


2. Auto-generate a class based on some JSON

Have you ever needed to create a C# class/POCO based on some JSON being returned by an API? Instead, of manually creating these types of classes yourself and then going through the faff of modeling all the properties, instead, make Visual Studio do the hard work for you. First, get some JSON and copy it to your clipboard.

Visual Studio Auto-generate a class based on some JSON

Next, you will need to create a new file to store the code. After doing this, you can generate the code by using this option:

EditPaste SpecialPaste JSON as Class

After doing this, Visual Studio will generate all the classes, sub-classes, and properties within that file which will all be based on that copied JSON!


3. Drag Code Onto The Toolbox

If you want an easy way to store a snippet of code, did you know that you can make use of the toolbar? When you know that you'll need to re-use some bit of code throughout your project, all you need to do is select that code and then drag it onto the toolbar. Doing this will automatically create a shortcut, which you can then rename and re-use.

Visual Studio Drag Code Onto The Toolbox

With the code snippet shortcut created, all you need to do is drag the shortcut onto any line within any file and that code snippet will be automatically pasted into Visual Studio 😊


4. Sync with Active Document

This feature is really useful if you consistently find yourself trying to find the active tab within Solution Explorer. The Sync with Active Document button will automatically locate the currently opened file within Solution Explorer:

Sync with Active Document button Visual Studio

It's very easy to miss this button within the UI, however, if you like me and lose your position while coding often, this button will help!


5. Remember Pinned Tab Status

I often use pinned tabs, however, a really annoying feature is that whenever you close a tab its pinned status will be lost. This is extremely annoying when you are working on a large solution and you have pinned 9-10 tabs and you close all your tabs accidentally. If you do this, your only option is to open everything and re-pin the files all over again. If this has happened to you, fear not as Visual Studio has a pin status feature!

The Remember the pin status feature is turned off by default, which is why you might not have known about this capability, however, you can enable it pretty easily by opening this setting:

ToolsOptionsEnvironmentTabs and WindowsMaintain pin status if the document is removed from well

With the feature enabled, your pinned status will now be retained regardless if you close a tab or not!


6. Clipboard History

Did you know that Visual Studio has a clipboard history? If you need to copy several bits of code at the same time, instead of constantly jumping between two active documents, you can copy everything in a batch and then retrieve each item individually from the clipboard history as you need it!

Exploring 10 Lesser Known Features Within Visual Studio 2022 - Clipboard History

To access the history, instead of using the usual Ctrl + V, you will need to press Ctrl + Shit +V instead. Doing this will launch the clipboard history UI. From this UI, you are then free to select the exact code snippet that you want to paste.


7. Create project reference with drag and drop

This is a very simple hack and won't save you much time, however, the reason why I bring it up here is that I only recently learned this was possible. When you have multiple class libraries, you will often need to create project references!

For over a decade I have created references by right-clicking on the class library selecting Add Project Reference and then enabling the checkbox next to the project I want to reference.

Create project reference with drag and drop in Visual Studio 2022

Instead of doing this, you can simply drag your project onto your class library and Visual Studio will then automatically create the reference for you. Simple but definitely a way to reduce unneeded clicking!


8. Block Select

Did you know Visual Studio has a block selection feature? Whenever you need to copy a very specific part of your code, it will be easier for you to use this. All you need to do is keep Alt selected and then using your mouse create a block. You can then copy anything within that block:

Exploring 10 Lesser Known Features Within Visual Studio 2022 - Block Select

The Block Select feature will definitely give you more fine-grained control over your copy and pasting!

9. Bookmarks

When you are working within a large solution, if you are like me you will typically need to jump between lots of different projects and files frequently. If you find yourself consistently getting lost within Visual Studio, the bookmark feature is something you should consider using. You can access the bookmark manager by pressing Cntrl + W and then B.

You might be wondering what is the benefit of using a bookmark rather than a pinned tab? Pinned tabs are useful for easy access to a file, however, where the bookmark feature comes into its own is that it will allow you to jump to a specific line within a file. Bookmarks are stored locally so you do on need to worry about your bookmarks being pushed into GIT and shared around the team!


10. Code Clean

The last feature in this list will automatically refactor your code whenever you click on save! Extensions like CodeMaid and Resharper, can be configured to automatically refactor your code as you work, however, it is also nice to be to get this capability without being forced into using a third-party extension if you do not want to. To enable this feature you will need to enable it from the Visual Studio settings:

ToolsOptionsText EditorCode CleanupRun code cleanup profile on save

After you enable the checkbox labeled Run code cleanup profile on save, whenever you save any of your code files Visual Studio will automatically try to tidy it up for you.

The cool thing about this feature is that you can create cleaning profiles that define what sort of tasks Visual Studio should try to perform. Within the same setting screen mentioned above, there is a link to the Configure Code Cleanup wizard. From here you can add different rules like removing unneeded using statements, removing trailing whitespace, as well as lots more.

This feature is not enabled by default, however, if you are not using any other refactoring tool you should enable this feature as it will save you a bunch of time


Happy Coding 🤘