Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to sort imports in alphabeticall order in Intellij?

Is it possible to force IntelliJ to order imports alphabetically? So it should add import in lexicographical order and sort all imports that are not in good order when formatting the code.

like image 747
tryingHard Avatar asked Dec 16 '19 10:12

tryingHard


Video Answer


1 Answers

Reformatting code optimizes the imports by default, but it is also possible to invoke Code | Optimize Imports separately. You can configure the order of imports under Preferences | Editor | Code Style | Java under the Import Layout header. By default imports are alphabetically ordered, except for java.* and javax.* imports.

like image 122
Bas Leijdekkers Avatar answered Oct 23 '22 04:10

Bas Leijdekkers