I'm working with intelliJ and my problem is when I start to import some temporary unused packages into my class file intellij delete those line within a second.
how can I turn off this not so nice feature?
I'm working with intelliJ and my problem is when I start to import some temporary unused packages into my class file intellij delete those line within a second.
how can I turn off this not so nice feature?
Disable File | Settings
| Editor
| General
| Auto Import
| Optimize imports on the fly.
Normally you don't need to add imports manually, IDEA does it for you.
Settings > Editor > General > Auto Import > Optimize imports on the Fly
, as in @merrick's answer. v14.1.4 –
Munshi String
and Set
imports into this one file and it produces error messages of course. Very annoying since it happens whenever imports are optimized for it –
Pampas For Scala developers: you can have enabled
Settings > Editor > General > Auto Import > Optimize imports on the fly
but add exclusions into
Settings > Editor > Code Style > Scala > Imports always marked as used:
In Intellij 14 :
Settings > Editor > General > Auto Import > Optimize imports on the fly.
(Update) For the Scala developers out there, you can have 1/2 the cake and eat the other 1/2 now: disable the auto-optimize for just scala
For me while using Go, this was caused by optimizing imports on save. IntelliJ IDEA -> Prefernces -> Tools -> Actions on Save -> Optimize imports.
The above answers are obviously the way to go. Here's another quick fix (a bad one at that) is to simply use it somewhere in your code
if (0) console.log(LibraryName.version);
This should only be a temporary measure though.
I use this to prevent the package from being yeeted:
import {Dropdown} from 'bootstrap';
(() => typeof Dropdown)();
© 2022 - 2024 — McMap. All rights reserved.
import scala.collection.JavaConverters._
. But IntelliJ doesn't auto-import when I type.asScala
at the end of an expression that returns a Java collection. So IMHO the option should be off by default for Scala code. – Gnawing