Reputation: 2515
I'm planning to move a widely used class from the non-standard package mycompany.etc
to the more standard com.mycompany.etc
. IDEA finds and updates references nicely, but when doing so, it updates import statements in-place without moving them according to the import order. The result is that they end up wildly out of place between all the remaining non-standard imports starting with mycompany
.
Is there a way to instruct IDEA to move the updated import statement, or better yet, automatically perform an 'optimize imports' on each file where imports were updated during refactoring?
Upvotes: 2
Views: 1038
Reputation: 2515
Given the fact that 8+ years later, as of 2024.2.4, a fully in-IDE solution still doesn't seem to exist, it's perhaps worth mentioning that I ended up writing a git hook that fixes the import order only in files that were changed or added in a particular commit.
Upvotes: 0
Reputation: 41
Maybe you should use "Optimize imports on the fly". Settings-> General-> Auto import-> Optimize imports on the fly
Upvotes: 0