Why do import statements disappear, as soon as you press Enter


In my Java project/Groovy Framework, I can't type in any import statements.  As soon as the import statement is typed, and Enter is pressed, it completely disappears.  There's nothing, not even a code folding situation; it just refuses to persist, in the source code file.

Comment actions Permalink

You are not supposed to type imports manually, IntelliJ IDEA will add imports for you automatically from the usages.

What happens is that you have optimize imports on the fly option enabled that removes unused imports.

Comment actions Permalink

Yep, I see that now, thanks Serge.


Please sign in to leave a comment.