Is it possible for intellij to organize imports the same way as in Eclipse?

后端 未结 4 1589
深忆病人
深忆病人 2020-12-04 05:04

I\'m working on a project where all the team members are using Eclipse and I\'m the only IDEA user. This creates a lot of noise from imports rearrangements. The order in whi

相关标签:
4条回答
  • 2020-12-04 05:23

    The best way is to use Eclipse Code Formatter plugin.

    0 讨论(0)
  • 2020-12-04 05:30

    Settings | Editor | Code Style | Java | Imports | Import Layout

    0 讨论(0)
  • 2020-12-04 05:33

    In update to Max's answer, the correct order for resolving the checkstyle warnings. I updated the following in IntelliJ:

    static all other, 
    blank 
    com.*
    java.* 
    blank
    javax.*
    org.*  
    all other imports
    
    0 讨论(0)
  • 2020-12-04 05:41

    Some more details: I ended up performing these steps to match out of the box eclipse organizing:

    (in Settings > Editor > Code Style > Java > imports, as mentioned by @yole)

    • set "class count to use import with '*'" to 99 (seems like you cannot turn this off)

    • set this ordering (like eclipse defaults):

      static all other, 
      blank, 
      java.*, 
      blank, 
      javax.*, 
      blank, 
      org.*, 
      blank, 
      com.*, 
      blank, 
      all other imports
      

    FWIW, there is an Intellij plugin called "eclipse code formatter" that I evaluated for this purpose and ended up discarding, because it set up a separate shortcut (in OSX) that was already in use by core IDE functionality.

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