Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop VS from automatically adding using directives

I don't mind the using directives which are automatically created when the script is created. Those are fine. What I'm talking about are the using directives which are automatically generated at the top of the script while I'm coding as soon as I refer to a type which is out of scope. A pox upon the silent fiends!

To clarify, currently if I try including a type which exists in some namespace which is not yet declared as 'using' in the script, said namespace will get auto-added to the top of the script. This is undesired behavior for me.

I simply prefer to manually add my namespaces.

like image 572
Nate H. Avatar asked May 15 '20 04:05

Nate H.


2 Answers

Under Tools > Options... > Text Editor > C# > IntelliSense, uncheck 'Show items from unimported namespaces (experimental)'.

like image 51
Nate H. Avatar answered Nov 20 '22 06:11

Nate H.


Even I find this annoying. I was able to turn this off in VS 2022 using the following options. Hope this helps some one.

I do agree that Microsoft should give us an option to list the items from unimported namespaces but not add using statements automatically.

enter image description here

like image 2
Shreedhar Kotekar Avatar answered Nov 20 '22 07:11

Shreedhar Kotekar