idea中删除无用的import快捷键是什么

在 IntelliJ IDEA 中,您可以使用以下快捷键来删除无用的 import:

  • Windows/Linux:Ctrl + Alt + O
  • macOS:Option + Command + O

这将自动删除所有未使用的 import,并将代码中的 import 优化为最小值。

如果您想要定期清理无用的 import,也可以通过以下步骤来启用自动 import 清理功能:

  1. 打开 IntelliJ IDEA 的设置(Preferences)对话框。
  2. 在左侧窗格中选择“Editor”,然后单击“Auto Import”。
  3. 在右侧窗格中,将“Optimize imports on the fly”和“Add unambiguous imports on the fly”选项都选中。
  4. 单击“Apply”按钮并关闭设置对话框。

现在,当您编辑代码时,IntelliJ IDEA 将自动检测和清理未使用的 import,并在需要时添加所需的 import。

未经允许不得转载:国外服务器评测 » idea中删除无用的import快捷键是什么