I want to format my code according to the Google Java Style.
There are some issues when it comes to import statements. The one rule I can not fulfill other than by manual editing each class is this one:
If there are both static and non-static imports, a single blank line separates the two blocks.
Apparently, there is no way to configure the Organize Imports action in Eclipse to add this blank line.
Are there any workarounds, plugins or plans to add such a feature (or is my only choice to write one myself or use a different IDE)?
I think this issue is related to the formatter used rather than the Organize Imports action per se.
The formatter options are available at Window > Preferences > Java > Code Style > Formatter. When editing a profile, there's a tab named Blank Lines and an option Between import groups which you may find useful.
When I have this option set to 1, Organize Imports action inserts a blank line between import group and import static group.
It's quite straightforward in Eclipse, here's how to do it:
In "Organize imports" define only two groups:
In the formatter set Blank Lines → Blank lines in compilation unit → Between import groups to 1.
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