Search code examples
javaintellij-idea

How to delete all unused imports from current project in Intellij Idea


I have been using Intellij Idea for quite some time now. I have a few questions though. Is there a way to delete all unused imports from all files in the current project?

I know that I can choose menu item Code > Optimize Imports (CTRL + ALT + O) to organize imports in individual files but since the application that I am working on has hundreds of files, this process does not make any sense. If there is no way of doing this, can I create a macro for this? If so, how do I do it?


Solution

  • Click the project folder, then enter CTRL + ALT + O. It will handle all files under the folder:

    enter image description here