Is there a way in Visual Studio (a hotkey) to automatically import a type (or choosing between known namespaces) like the Ctrl + O in Eclipse?
Asked
Active
Viewed 6.7k times
73
-
possible duplicate of [Visual Studio Keyboard Shortcut to automatically add the needed Using statement](http://stackoverflow.com/questions/148977/visual-studio-keyboard-shortcut-to-automatically-add-the-needed-using-statement) – nawfal Feb 16 '13 at 18:13
3 Answers
80
Yes, Visual Studio can add the using
for you. When you type in a class name, hit Ctrl + . and then Enter (the first option is 99.99% the right one, so just hit Enter). And you can have it add the using
at the top of the file for the namespace of that class. I use it all the time.
This is easier than Shift + Alt + F10 + Enter as it's fewer keys and the . and Enter are closer.

Peter Mortensen
- 30,738
- 21
- 105
- 131

mattlant
- 15,384
- 4
- 34
- 44
-
1Yeah, CTRL + . is shorter - Thanks for the tip. Sounds buggy too in VB.NET – Larry Oct 09 '08 at 12:16
-
2I don't think this exists in express editions. I think I need to stop being cheap. – Oh Danny Boy Apr 08 '13 at 19:05
-
Thanks. There are surprising a lot of wrong answers to this question out there – Evorlor Feb 02 '14 at 19:11
-
1Your cursor needs to be on the class/interface name you typed for this to work. – Pranav Mahajan Sep 19 '14 at 12:27
-
-
-
55
When the red caret appears at the end of your member, just hit Shift + Alt + F10, then use arrows keys to choose the right option:

Peter Mortensen
- 30,738
- 21
- 105
- 131

Larry
- 17,605
- 9
- 77
- 106
-
7That doesn't automatically add the right 'using' declaration though. Resharper will. – Andrew Oct 09 '08 at 11:54
-
2Your cursor needs to be on the class/interface name you typed for this to work. – Pranav Mahajan Sep 19 '14 at 12:27
-
2wow, that's totally intuitive and absolutely easy to do with one hand - wtf microsoft? – m02ph3u5 Jul 13 '15 at 15:22
-
6
Look at JetBrain's excellent ReSharper product. It does this for you.

Andrew
- 11,894
- 12
- 69
- 85
-
I lost my `Alt` + `Enter` shortcut and had to go searching for it. The binding is `ReSharper_AltEnterFeelingLucky` – Joseph Lennox Oct 19 '16 at 22:55
-