IntelliJ Idea 12: How do I auto import namespaces?

2019-01-23 22:30发布

In Eclipse, I can hit the Ctrl+Shift+O shortcut to auto import namespaces. How do I do it in IntelliJ IDEA Community Edition?

4条回答
We Are One
2楼-- · 2019-01-23 23:00

You can type AltEnter to show a dropdown of possible classes to auto-import, it's similar to Eclipse.

I found this in Android Studio on Mac OS X - if I mouse over the class name it can't find, you get a suggestion pop-up that shows this shortcut

查看更多
我想做一个坏孩纸
3楼-- · 2019-01-23 23:03

Code > Optimize Imports will provide you the behavior you are after. If you want to adjust the settings you can so via Settings > Editor > Auto Import.

enter image description here

查看更多
做个烂人
4楼-- · 2019-01-23 23:17

IntelliJ ShortCut depends on Keymap:

enter image description here

You can customize shortcut for your favorite commands.

查看更多
迷人小祖宗
5楼-- · 2019-01-23 23:22

You can try this: "Ctrl+Alt+O" . enter image description here

查看更多
登录 后发表回答