Press Ctrl+Alt+S to open the IDE settings and select Tools | Actions on Save. Enable the Optimize imports option. Additionally, from the All file types list, select the types of files in which you want to optimize imports. Apply the changes and close the dialog.
Open the 'Settings' (or 'Preferences' in mac) window and goto Editor > Code Style > Java. Click on 'Imports' tab. In 'Import Layout' area, you can arrange the import order by selecting the import type and clicking on the arrow (see image below). Once the changes are done apply the new settings.
Automatically organise import statements whenever you save Here are the steps to organising imports whenever you save: Go to Window > Preferences > Java > Editor > Save Actions. Select Perform the selected actions on save (off by default). Ensure that Organize imports is selected (on by default).
In Eclipse, go to Window->Preferences, and select General->Appearance. You can change the font in there. I don't know what IntelliJ uses, but you can probably look it up in IntelliJ, and just match it.
Some more details: I ended up performing these steps to match out of the box eclipse organizing:
(in Settings
> Editor
> Code Style
> Java
> imports
, as mentioned by @yole)
set "class count to use import with '*'" to 99 (seems like you cannot turn this off)
set this ordering for Import Layout
(like eclipse defaults):
static all other,
blank,
java.*,
blank,
javax.*,
blank,
org.*,
blank,
com.*,
blank,
all other imports
FWIW, there is an Intellij plugin called "eclipse code formatter" that I evaluated for this purpose and ended up discarding, because it set up a separate shortcut (in OSX) that was already in use by core IDE functionality.
Settings | Editor | Code Style | Java | Imports | Import Layout
The best way is to use Eclipse Code Formatter plugin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With