如何在Intellij Idea中删除当前项目中所有未使用的导入

如何在Intellij Idea中删除当前项目中所有未使用的导入

问题描述:

我已经使用 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?

我知道我可以选择菜单项 Code > Optimize Imports ( CTRL + ALT + O )来组织单个文件中的导入,但是由于我正在处理的应用程序具有数百个文件,因此此过程没有任何意义.如果无法执行此操作,是否可以为此创建一个宏?如果是这样,我该怎么办?

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?

单击项目文件夹,然后输入 CTRL + ALT + O .它将处理该文件夹下的所有文件:

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