Search code examples
javaimportautomationintellij-idea

How to remove unused imports in Intellij IDEA on commit?


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 but it's still manual.


Solution

  • When you commit, tick the Optimize imports option on the right. This will become the default until you change it.

    I prefer using the Reformat code option as well.