Did you know – Visual Studio can add Using directive automatically on paste?

Did you know – Visual Studio can add Using directive automatically on paste?

In this post, let us learn how to add Using directive automatically while pasting a line of code in Visual Studio. Visual Studio always brings improvements with developer productivity. No matter how small some of the features are, they always help improve developer productivity. One such part is Add missing using directives on paste. This feature automatically adds a directive when you paste a line of code. However, it’s turned off by default. You need to turn it on before you see it in action.

Add Using directive automatically on Paste

To turn on this feature, navigate to Tools > Options > Text Editor > C#. and select Add missing using directives on paste. Refer to the below image.

selection missing directives option

Related Tip: Using or Using ?

Once this is enabled, in the code editor, whenever you paste some line, which has reference assembly and the directives are not included, it will be automatically included.

Check this out in action.

Hope this helps.

Read : Exploring Azure DevOps APIs

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

2 Comments to “Did you know – Visual Studio can add Using directive automatically on paste?”

Comments are closed.