Mykhaylo Adamovych
Mykhaylo Adamovych

Reputation: 20986

How to remove unused imports using Eclipse and not reorganize it?

Organize imports (<Ctrl>+<Shift>+O) is well known feature of Eclipse.
How could I remove only unused imports, but not reorganize it (not unfold .* and not change line ordering)?

Upvotes: 3

Views: 1358

Answers (4)

Sir. Hedgehog
Sir. Hedgehog

Reputation: 1300

You can do it very easily upon saving a Java file by:

Window -> Preferences -> Java -> Editor -> Save Actions -> Check Additional Actions -> Configure -> Unnecessary Code -> Check on Remove Unused Imports

Upvotes: 1

djm.im
djm.im

Reputation: 3323

As I know it is not possible automatically do.

You can repeat this steps

  1. Ctrl + . (This will move cursor to the next error or warning
  2. Ctrl + 1 - show hints
  3. Remove unused import

Upvotes: 0

dsh
dsh

Reputation: 12234

You can simply delete the lines with the yellow squiggle underline.

Upvotes: 0

SantiBailors
SantiBailors

Reputation: 1634

You can try menu Source / Clean Up / Use custom profile and configure it to only do the "Remove unused imports".

Upvotes: 6

Related Questions