How to prevent IntelliJ IDEA from deleting unused packages?

前端 未结 4 2100
一整个雨季
一整个雨季 2020-12-01 07:20

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

相关标签:
4条回答
  • 2020-12-01 07:32

    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.

    0 讨论(0)
  • 2020-12-01 07:32

    (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

    0 讨论(0)
  • 2020-12-01 07:38

    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:
    

    0 讨论(0)
  • 2020-12-01 07:41

    In Intellij 14 : Settings > Editor > General > Auto Import > Optimize imports on the fly.

    0 讨论(0)
提交回复
热议问题