Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 452
ahsteele Avatar asked Jan 21 '11 21:01

ahsteele


People also ask

What is the shortcut to import in Eclipse?

Press: CTRL + SHIFT + O and you should see below dialog boxes. Choose your desired import package and click next. It will prompt you for your next import and thats it.

What is the shortcut key of import file?

Ctrl + Shift + M : Add import for currently selected.

What is Ctrl D in Eclipse?

Ctrl + D. Deletes current line in the editor. Command + Shift + O.


2 Answers

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

like image 200
Crembo Avatar answered Sep 30 '22 20:09

Crembo


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).

like image 45
Chris Roberts Avatar answered Sep 30 '22 18:09

Chris Roberts