IntelliJ IDEA code reformat options
Asked Answered
C

2

18

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?

Clancy answered 18/2, 2012 at 22:17 Comment(0)
A
21

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!

Alsacelorraine answered 18/2, 2012 at 22:27 Comment(3)
In Intellij 14 this has moved to File > Settings > Editor > General, and then under a "Formatting" section within General.Chaetopod
In intellij 14.1.1, there is not setting. It is moved to a new key binding shift + Cmd + Alt + L which always shows the dialogTosh
@RajaniKaruturi this saved my day. I have been looking all over for this setting since I upgraded to 14.1+. ThanksBettencourt
P
7

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.

Pironi answered 22/8, 2018 at 8:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.