How to remove unused imports in Intellij IDEA on commit?
In Mac IntelliJ IDEA, the command is Cmd + Option + O
For some older versions it is apparently Ctrl + Option + O.
(Letter O not Zero 0) on the latest version 2019.x
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.
If you are using IntelliJ IDEA or Android Studio:
Go to Settings > Editor > General >Auto Import and check the Optimize imports on the fly checkbox.