Does IntelliJ have an Organize Imports feature similar to that in Eclipse? What I have is a Java file with multiple classes missing their imports. Example:
p
Shortcut for the Mac: (ctrl + opt + o)
If you are missing just one import (the class name has red underline), click and hover the mouse over it, and a blue suggested import statement will appear. If you hit, Alt + Enter at this point, the import will be included in the file and the red underline should disappear.
Just move your mouse over the missing view and hit keys on windows ALT + ENTER
navigate to the file where you want to organize imports or just click on the whole package or even click on the project than press CTRL + ALT + O
ALT+ENTER was far from eclipse habit ,in IDEA for me mouse over did not work , so in setting>IDESetting>Keymap>Show intention actions and quick-fixes
I changed it to mouse left click , It did not support mouse over! but mouse left click was OK and closest to my intention.
I finally created a workaround around this frustrating issue. I'm not completely happy with the workaround, but it's better than nothing.
Basically, after you paste the source code and unambigous imports are fixed, just press F2
to highlight the next compiler error. If the current error is an import-missing error, press Alt+Enter
, then Enter
to select the Import
option, then pick the correct import. Then, press F2
again.