How to remove unused imports in Intellij IDEA on commit?

前端 未结 9 1626
遥遥无期
遥遥无期 2020-12-23 02:57

Is there a way to remove unused imports in Intellij IDEA on commit?

It is not very optimal to do it manually, CTRL + ALT + O helps b

相关标签:
9条回答
  • 2020-12-23 03:18

    If you are using IntelliJ IDEA or Android Studio:

    Android optimize imports

    Go to Settings > Editor > General >Auto Import and check the Optimize imports on the fly checkbox.

    0 讨论(0)
  • 2020-12-23 03:24

    File/Settings/Inpsections/Imports and change "Unused import" to Error. This marks them more clearly in the Inspections gutter and the Inspection Results panel.

    0 讨论(0)
  • 2020-12-23 03:26

    You can check checkbox in the commit dialog.

    enter image description here

    You can use settings to automatically optimize imports since 11.1 and above.

    enter image description here

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