Eclipse keyboard command to add import statement

I am a C# developer who is doing some Android development in Eclipse. One of my favorite keyboard shortcuts in Visual Studio is CTRL + . which brings up the SmartTag menu. This is incredibly useful for adding using statements on the fly.

As an example if I don't have an import statement for System.Xml.Linq but create a variable of type XDocument I can quickly add the appropriate using with the keyboard command.

Is there a similar keyboard command available in Eclipse?


I'm pretty sure he has Ctrl + Shift + O in mind, but I may be wrong.

You can use Ctrl + Shift + O to "O"rganize Imports (like Crembo mentions). Another neat trick is to go to Windows > Preferences, search for "Save Actions", and check "Organize Imports". Now whenever you save (Ctrl + S), Eclipse will automatically run the "organize imports" feature. I find this quicker, since it's quicker for me to hit Ctrl + S than Ctrl + Shift + O (one-hand shortcut versus two-hand shortcut).

For Mac users the shortcut is:

CMD + Shift + O

some useful Eclipse shortcuts, you need first one

1. Ctrl + Shift + O : Organize imports

  1. Ctrl + D : Delete row

  2. Ctrl + 1 : Activate quick fix

  3. Ctrl + O : Open declarations

  4. Ctrl + / : Line Comment

  5. Alt + Shift + R : Rename selected element

  6. Ctrl + Shift + L : Shortcut for shortcuts

if you need more refer here

The easiest thing to do is to start typing the type name, then press Ctrl + Space to get the completions. Selecting the completion will complete the type name that you are typing and will also add the import statement. Short of that, there is Ctrl + 1, which will bring up quick fixes when you are over a piece of code with problem. There is typically a quick fix to import type.

In Preferences->General->Key, you can have your bindings for shortcut key. This article: Eclipse Short Cut Keys lists some useful shortcuts.

Need Your Help

Convert RGB to Black & White in OpenCV

c++ c image-processing opencv computer-vision

I would like to know how to convert an RGB image into a black & white (binary) image.

My Wpf Application cannot locate resource 'Mainwindow.xaml'

wpf xaml

I have been working on a wpf application using , i recently run into a problem...