简体   繁体   中英

How to remove unused imports using Eclipse and not reorganize it?

Organize imports ( <Ctrl>+<Shift>+O ) is well known feature of Eclipse.
How could I remove only unused imports, but not reorganize it (not unfold .* and not change line ordering)?

您可以尝试菜单源/清理/使用自定义配置文件,并将其配置为仅执行“删除未使用的导入”。

您只需删除带有黄色波浪线下划线的线条即可。

As I know it is not possible automatically do.

You can repeat this steps

  1. Ctrl + . (This will move cursor to the next error or warning
  2. Ctrl + 1 - show hints
  3. Remove unused import

您可以通过以下方式保存Java文件,从而轻松完成:

Window -> Preferences -> Java -> Editor -> Save Actions -> Check Additional Actions -> Configure -> Unnecessary Code -> Check on Remove Unused Imports

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM