How to optimize imports automatically after each save in IntelliJ IDEA

前端 未结 4 1590
孤街浪徒
孤街浪徒 2020-12-13 23:13

I want to learn how can I automatically optimize imports after each save as we do Eclipse(save actions).

相关标签:
4条回答
  • 2020-12-13 23:26

    The mentioned answer works, but there is also the Intellij "save actions" plugin available from the JetBrains plugin repository that does that (as well as other things): Intellij Save Actions Plugin.

    Installation

    File > Settings > Plugins > Browse repositories... > Search 'Save Actions' > Category 'Code tools'

    Disclaimer

    I'm the plugin developer

    0 讨论(0)
  • 2020-12-13 23:31

    In version 'Ultimate 2016.2' it is:

    File > Other Settings > Default Settings > Auto Import > Optimize imports on the fly

    0 讨论(0)
  • 2020-12-13 23:32

    First step:

    CTRL + SHIFT + A or CMD + SHIFT + A (for mac)
    

    Second step:

    Search Optimize imports

    Third step:

    Switch ON the option

    0 讨论(0)
  • 2020-12-13 23:45

    IntelliJ IDEA offers an option to Optimize imports on the fly in Settings | Editor | General | Auto Import and Optimize imports option in the Commit Project dialog.

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