Redirect |
---|
location | https://www.jetbrains.com/help/idea/managing-imports-in-scala.html |
---|
|
IntelliJ IDEA lets you manage your imports in Scala the same way as it does in other languages.
...
In the Settings dialog, select
→→→ span |
---|
|
Imports Wiki Markup |
---|
{span:class=shortcut}Project Settings{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Code{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Scala{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Imports{span} |
.

- Class count to use import with '_' - in this text field, specify the number of classes to be imported from a single package until all statements importing a single class are substituted with a statement importing an entire package.
...
- Import members using '_' - If you select this check box then IntelliJ IDEA imports all members such as fields or methods from an included in the object. If the check box is cleared, IntelliJ IDEA imports only a specific member such as method or a field from the object.
- Use the shortest path when trying to import reference with already imported name - select this check box to let IntelliJ IDEA find the shortest available path when you import the reference with already imported name using code compleationcompletion.
- Classes to use only with prefix - this area lets you view the list of classes with prefixes. You can add a pattern to use appropriate classes only with prefix or you can remove a class from the list.
...
In the Settings dialog, select
→→ Wiki Markup |
---|
{span:class=shortcut}IDE Settings{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Editor{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Auto Import{span} |
.
You can select the following options:
...
Note |
---|
If you skip an import suggested in the Ask mode or choose the None mode, the non-imported classes will be red-highlighted and an import pop-up window will appear to help you create import statements using the Alt+Enter keyboard shortcut. |
- Add unambiguous imports on the fly - select this check box to have IntelliJ IDEA automatically add imports that can be added without user intervention.
3.Optimizing Imports
You can optimize imports using
→ span |
---|
|
Optimize Importsselecting Wiki Markup |
---|
{span:class=shortcut}Code{span} |
→ Wiki Markup |
---|
{span:class=shortcut}Optimize Imports{span} |
command.

In this dialog box, specify from where you want IntelliJ IDEA to remove unused import statements, in order to optimize the import procedure.
...
Start typing a name in the editor.

In the Class to Import suggestion Import suggestion list, click
Wiki Markup |
---|
{span:class=shortcut}Alt{span} |
+
Wiki Markup |
---|
{span:class=shortcut}Enter{span} |
, and click the right arrow to reveal the nested list of intention actions. IntelliJ IDEA suggests you to exclude specific class or the whole containing package.

In the dialog that opens perform necessary changes and click OK.
