IntelliJ IDEA lets you manage your imports in Scala the same way as it does for other languages.
You can configure the improrts in the Project Settings.
Project Settings→Code→Scala Imports
- 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.
- Add import statement in closest block - select this check box to add your import statement to the closest block instead of the top of your code.
- Add fully qualified imports - select this check box to add fully qualified imports.
- Sort imports lexicographically (for optimize imports) - use this check box if you want IntelliJ IDEA to sort your imports in lexicographical order. However, if Add fully qualified imports check box is selected then
- Collect imports with the same prefix into one import - use this check box if you want IntelliJ IDEA to insert all imports with the same prefix into one.
- Import members using '_' - select this check box to import all members of the package (this is analogous to import members using'*' in Java)
- Use the shortest path when trying to import reference with already imported name
- 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.
- Import Layout - this area lets you view the layout of the import statements, add or remove blank lines between them, and add or remove package names. You can also move the rows in the layout up or down .
You also can configure your imports through the IDE Settings.
IDE Settings→Editor→Auto Import
You can select the following opions:
- Insert imports on paste - use this drop-down list to define how IntelliJ IDEA will insert imports for pasted blocks of code, if they contain references to classes that are not imported into the target class.
The available options are:
All - select this option to have IntelliJ IDEA automatically add import statements for all classes that are found in the pasted block of code and are not imported in the current class yet.
Ask - if this option is selected, when pasting code blocks, IntelliJ IDEA will open a dialog box, where you can choose the desired imports.
None - select this option to suppress import.
- Optimize imports on the fly - select this check box to have the Optimize Imports operation automatically performed for your files.
- Add unambiguous imports on the fly - select this check box to have IntelliJ IDEA automatically add imports that can be added without user intervention.