我正在使用 intelliJ,我的问题是,当我开始将一些临时的未使用的包导入到类文件 intelliJ 时,会在一秒钟内删除这些行。
我怎样才能关闭这个不太好的功能?
Disable File | Settings | Editor | General | Auto Import | Optimize imports on the fly.
File | Settings
Editor
General
Auto Import
Normally you don't need to add imports manually, IDEA does it for you.
In Intellij 14 : Settings > Editor > General > Auto Import > Optimize imports on the fly.
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 Scala developers: you can have enabled Settings > Editor > General > Auto Import > Optimize imports on the fly but add exclusions into
Settings > Editor > General > Auto Import > Optimize imports on the fly
Settings > Editor > Code Style > Scala > Imports always marked as used:
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.
For me while using Go, this was caused by optimizing imports on save. IntelliJ IDEA -> Prefernces -> Tools -> Actions on Save -> Optimize imports.