简体   繁体   中英

Intellij idea auto import across files

I have auto import enabled in idea, but it requires me to open the file in the editor (like it should). Now, i have done some regex magic, which means across 100+ classes i am using new classes that need to be imported. Since its all done with find/replace, those files have never been opened in the editor, and therefore the new classes havent been auto imported. Is there any way to run auto import unambiguous references across all files? cause currently, i have to compile, and then open all the files from the errors window? Optimize imports aparently doesnt do new imports.

I am not sure in which version of IntelliJ this feature became available (I am currently using 2017.1.1) but you can select a package from the project browser and in the context menu optimise imports for that package or use the keyboard shortcut Ctrl + Alt + o .

I just used this to update the imports of all my classes after changing my import settings and it worked like charm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM