IntelliJ Organize Imports

后端 未结 14 1000
孤街浪徒
孤街浪徒 2020-12-02 04:48

Does IntelliJ have an Organize Imports feature similar to that in Eclipse? What I have is a Java file with multiple classes missing their imports. Example:

p         


        
14条回答
  •  失恋的感觉
    2020-12-02 05:41

    In addition to Optimize Imports and Auto Import, which were pointed out by @dave-newton and @ryan-stewart in earlier answers, go to:

    • IDEA <= 13: File menu > Settings > Code Style > Java > Imports
    • IDEA >= 14: File menu > Settings > Editor > Code Style > Java > Imports (thanks to @mathias-bader for the hint!)

    There you can fine tune the grouping and order or imports, "Class count to use import with '*'", etc.

    Note:
    since IDEA 13 you can configure the project default settings from the IDEA "start page": Configure > Project defaults > Settings > .... Then every new project will have those default settings:

提交回复
热议问题