Key Shortcut for Eclipse Imports
JavaEclipseJava Problem Overview
It's been a while since I last used Eclipse. I used to love this handy key shortcut that added all the imports to the top of the source file, but I've forgotten it. Does anyone know what this shortcut is?
Java Solutions
Solution 1 - Java
Ctrl + Shift + O (<-- an 'O' not a zero)
Note: This shortcut also removes unused imports.
Solution 2 - Java
Some useful shortcuts. You're looking for the 1st one...
- Ctrl + Shift + O : Organize imports
- Ctrl + Shift + T : Open Type
- Ctrl + Shift + F4 : Close all Opened Editors
- Ctrl + O : Open declarations
- Ctrl + E : Open Editor
- Ctrl + / : Line Comment
- Alt + Shift + R : Rename
- Alt + Shift + L : extract to Local Variable
- Alt + Shift + M : extract to Method
- F3 : Open Declaration
Source Here
Solution 3 - Java
Some other useful shortcuts:
-
Alt + Shift + R : Rename
-
Alt + Shift + Y : Word wrap
-
Alt + Shift + V : Move the selected elements
-
Alt + Shift + I : Inline refactoring
-
Alt + Shift + M : Extract Method refactoring.
-
Alt + Shift + L : Extract Local Variable
-
Alt + Shift + A : Block selection mode
-
Alt + Shift + Arrow Keys: selects enclosing elements
-
Alt + Shift + F1: Focus on eclipse element to know plugin implementation details.
-
Alt + Shift + F2: Plugin implementation details.
-
F4 : Type Hierarchy
-
Ctrl + Shift + T : Open Type
-
Ctrl + Shift + H: Open Type in Hierarchy
-
Ctrl + Alt + H: Call Hierarchy
-
Ctrl + Shift + G: Reference in workspace
-
Ctrl + Alt + G: Quick Search for selected text
-
Ctrl + Shift + O: Organize imports
-
Ctrl + Shift + M: Add import for currently selected.
-
Ctrl + Shift + L: Shows you a List of your currently defined shortcut keys
-
Ctrl + Shift + U: Occurrence in current file
-
Ctrl + Shift + A: Open plug-in Artifact
-
Ctrl + Shift + {: Two side by side editors with current file
-
Ctrl + Shift + Space : Parameter Hints
-
Ctrl + Shift + Mouse hover : To view javadoc
-
Shift + Mouse hover : To view source code
-
Ctrl + Space : Content Assist
-
Ctrl + F3/O : Outline
-
Ctrl + T: Type Hierarchy
-
Ctrl + H : Open Search Dialog
-
Ctrl + 1 : Quick Fix
-
Ctrl+Shift+NUM_KEYPAD_DIVIDE : Collapse All code blocks
-
Ctrl+Shift+NUM_KEYPAD_MULTIPLY : To open all code blocks
-
Alt + left arrow : Open recently closed file
Ctrl+Shift+ any key :Direct actions (on text mostly)
Alt+Shift+ any key : Indirect actions
Ctrl It is originally used with other chars by shell for perform special function. (In Mac Command)
Alt It enables alternate uses for other keys.
The above shortcuts are default, if we want to change shortcuts we can do. In eclipse -> Windows -> preferences -> keys. Where we can find all shortcuts with full details:
and
https://shortcutworld.com/IntelliJ-IDEA/win/IntelliJ_Shortcuts
https://shortcutworld.com/Eclipse/win/Eclipse-Helios_Shortcuts
https://www.jetbrains.com/help/idea/migrating-from-eclipse-to-intellij-idea.html#Shortcuts
Solution 4 - Java
You also can enable this import as automatic operation. In the properties dialog of your Java projects, enable organize imports
via Java Editor
- Save Action
. After saving your Java files, IDE will do organizing imports, formatting code and so on for you.
Solution 5 - Java
IntelliJ just inserts them automagically; no shortcut required. If the class name is ambiguous, it'll show me the list of possibilities to choose from. It reads my mind....
Solution 6 - Java
Ctrl+Space : Show Imports
This displays imports as you're typing a non-standard class name provided the proper references have been added to the project.
This works on partial or complete class names as you are typing them or after the fact (Just place the cursor back on the class name with squigglies).
Solution 7 - Java
CTRL + 1 can also be used which will suggest to import.
Solution 8 - Java
For static import select the field and press Ctrl+Shift+M