ryskajakub
ryskajakub

Reputation: 6421

IntelliJ IDEA code reformat options

When I press Ctrl + Alt + L, IDEA removes unused import. I want to turn this feature off, leave the unused imports there. Where can I affect this setting?

Upvotes: 18

Views: 6959

Answers (2)

RemusS
RemusS

Reputation: 1545

In IDEA 2018, you can hit Ctrl + Alt + Shift + L and the reformat file pop-up will appear. Then you can check/uncheck the "Optimize Imports" option.

Upvotes: 7

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340708

First check:

File | Settings | Editor | Formatting | Show "Reformat Code" dialog

Then when you hit Ctrl + Alt + L pop-up dialog will appear.

Uncheck Optimize imports and check Do not show this dialog in the future. Hit Enter or click Run. That's it!

Upvotes: 21

Related Questions