I have been doing some Android development and found that Ctrl+Shift+O shortcut is quite handy for someone like me who is still getting used to what imports are necessary for different objects on the screen. I have also been doing vb.net development in Visual Studio 2008 and by mistake tried that shortcut however it tried opening a form or something similar. So my question is: is there a shortcut that lets us import all missing references or remove the unnecessary ones in Visual Studio 2008?
2 Answers
To Remove Unnecessary Import Directives
I can confirm that in Visual Studio 2012 and Visual Studio 2010 there is a context menu option for the code-editor to remove, sort or remove and sort using directives in either Visual Basic.NET or C#. I've actually never used Visual Studio 2008 but a quick search reveals that it is possible in 2008 too (source).
In order to hook this functionality up to a hotkey all you need to do is:
- Go to Tools > Options
- Expand the root node annotated 'Enviroment' and then click the node annotated 'Keyboard'
- Search for Edit.RemoveAndSort and assign your hotkey of choice.
To Add Unknown Import Directives
I use this plugin called ReSharper which presents me with an interface like this when I reference a class that does not have an appropriate import directive:
If you don't want to use ReSharper (it's pretty expensive) then Visual Studio has a slightly less productive but just as effective interface. You should see the class reference underlined in red and if you hover your mouse to the red line you should see a little dialog displaying the option to add a reference to the namespace. You can also press CTRL + .
to show the dialog quickly.

- 7,714
- 2
- 28
- 46
-
exactly what i needed. Thanks a bunch and +1 for effort – Mar 15 '13 at 16:15
-
That's View.ShortSmartTag, which is quite dope, to be fair, but doesn't fix all your usings in one fell swoop, which Ctrl+Shift+O does for Java's imports in Eclipse. – Mathieu K. Feb 26 '17 at 04:21