IntelliJ IDEA 2016.3 Help

Auto Import

File | Settings | Editor | General | Auto Import for Windows and Linux
IntelliJ IDEA | Preferences | Editor | General | Auto Import for OS X
Ctrl+Alt+S
/help/img/idea/2016.3/settings.png


XML

Show import pop-upAutomatically display an import pop-up dialog box when typing the name of an unbound namespace.

Java

Insert imports on pasteUse 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.
Show import pop-upAutomatically display import pop-up dialog box when typing the name of a symbol that lacks import statement.
Optimize imports on the flySelect this check box to have have the Optimize Imports operation automatically performed for your files.
Add unambiguous imports on the flySelect this check box to have IntelliJ IDEA automatically add imports that can be added without user intervention.
Exclude from Import and CompletionIn this area, create a list of packages and classes that should not be automatically included in the import statements.

Note that you can exclude packages and classes both on the project level and on the IDE level. This can be done in the cells of the Scope column:

/help/img/idea/2016.3/ij_exclude_from_import.png

Use:

  • /help/img/idea/2016.3/new.png (Alt+Insert) to enter the name of the class/package to be excluded from import and completion.
  • /help/img/idea/2016.3/delete.png (Alt+Delete) to remove the selected item from the list.

TypeScript

Show import pop-upAutomatically display import pop-up dialog box when typing the name of a symbol that lacks import statement.
Merge imports for symbols from the same module
Use paths relative to tsconfig.jsonWhen this check box is selected, IntelliJ IDEA calculates import paths using the tsconfig.json file as the root. When this check box is cleared, IntelliJ IDEA calculates import paths relative to the project root.

For example, if your project is structured as follows:

/help/img/idea/2016.3/ws_ts_import_example.png

With the check box selected, IntelliJ IDEA generates the following import statement:

import {ClassName} from 'directory_2/file_2'

If the check box is cleared, the following import statement is generated:

import {ClassName} from '../directory_2/file_2'

JSP

Add unambiguous imports on-the-flySelect this check box to have IntelliJ IDEA automatically add imports that can be added without user intervention.

Scala

Insert imports on pageUse 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.
To disable import import pop-up, use Java settingsRefer to the same options in the settings for Java.
Add unambiguous imports on the flySelect this check box to have IntelliJ IDEA automatically add imports that can be added without user intervention.
Optimize imports on the flySelect this check box to have have the Optimize Imports operation automatically performed for your files.

PHP

Enable auto-import in file scopeSelect this check box to have IntelliJ IDEA automatically import PHP namespaces, add use statements, and complete short class names on the fly, when you are typing in a class or file that does not belong to any specific namespace. By default, the check box is cleared.
Enable auto-import in namespace scopeSelect this check box to have IntelliJ IDEA automatically import PHP namespaces, add use statements, and complete short class names on the fly when you are typing in a class or file that belongs to a certain namespace. The check box is selected by default.

See Also

Last modified: 7 December 2016