Organize Imports Automatically

前端 未结 4 2011
花落未央
花落未央 2020-12-04 21:14

When using Eclipse, I find myself typing Ctrl+Shift+O several times, to organize imports (usually imports which are no longer required, generating warnings).

Is ther

相关标签:
4条回答
  • 2020-12-04 21:18

    Either: <project>->Properties->Java Editor->Save Actions

    Or

    Windows->Preferences->Java->Editor->Save Actions

    0 讨论(0)
  • 2020-12-04 21:20

    Preferences->Java->Editor->Save Actions->Configure...

    You can configure the removal of unused imports when saving from the Unnecessary Code tab.

    Adding imports would normally be done as you are writing the code otherwise it won't compile.

    This is how it looks like: enter image description here

    0 讨论(0)
  • 2020-12-04 21:23

    Yes, it is called Save Actions. There you can enable several thing should be done when saving a file.

    0 讨论(0)
  • 2020-12-04 21:32

    Doing while saving is great, but if you already have lots of files that need it applied to you can also select the package in the Package Explorer and go to Source->Organise Imports It will apply to each file below that package.

    You may be doing this already, I just wanted to make it clear that it can be applied to many files as can Source->Format.

    0 讨论(0)
提交回复
热议问题