IntelliJ IDEA 2018.1 Help

Auto Import

File | Settings | Editor | General | Auto Import for Windows and Linux
IntelliJ IDEA | Preferences | Editor | General | Auto Import for macOS
Ctrl+Alt+S settings


XML

Show import popupAutomatically display an import popup dialog box when typing the name of an unbound namespace.

Java

Insert imports on paste

Select how IntelliJ IDEA should process references to missing classes, static methods, or fields in pasted blocks of code:

All — import statements will be added automatically for all missing classes, methods and fields found in pasted blocks of code.

Ask — you will be prompted to select which classes, methods and fields you want to import.

None — no import statements will be added, you won't be asked about unresolved references.

Show import popup forSelect whether you want the IDE to show popups for classes and/or for static methods and fields. By default, both options are selected.
Optimize imports on the flyIf this option is on, IntelliJ IDEA removes unused imports, adds missing imports, and organizes import statements silently as you work in the editor.
Add unambiguous imports on the flyThis option enables automatic insertion of import statements if there's only one source of import.
Exclude from import and completionSpecify packages and classes that you want to exclude from the list of import and completion suggestions (the * (asterisk) wildcard is allowed). You can exclude items on the project or the IDE level.

TypeScript/JavaScript

Add ES6 imports automatically
  • If this checkbox is selected, IntelliJ IDEA automatically inserts an import statement in JavaScript code when you complete a symbol exported using ES6 exports in another project file:
  • When the checkbox is cleared, on pressing Alt+Enter IntelliJ IDEA shows a pop-up that suggests to import the completed symbol:
    ws es6 autoimport off
  • Completion and auto import also work for React components, including stateless components. IntelliJ IDEA properly detects them, provides code completion, and adds import statements automatically:
Add TypeScript imports automatically
  • If this checkbox is selected, IntelliJ IDEA automatically inserts an import statement in TypeScript code when you complete a symbol exported in another project file.
  • When the checkbox is cleared, on pressing Alt+Enter IntelliJ IDEA shows a pop-up that suggests to import the completed symbol.

JSP

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

Scala

Insert imports on paste

Select how IntelliJ IDEA should process references to missing classes in pasted blocks of code:

All — import statements will be added automatically for all missing classes, methods and fields found in pasted blocks of code.

Ask — you will be prompted to select which classes, methods and fields you want to import.

None — no import statements will be added, you won't be asked about unresolved references.

To disable import popup, use Java settingsRefer to the same options in the settings for Java.
Add unambiguous imports on the flyThis option enables automatic insertion of import statements if there's only one source of import.
Optimize imports on the flyIf this option is on, IntelliJ IDEA removes unused imports, adds missing imports, and organizes import statements silently as you work in the editor.

PHP

Enable auto-import in file scopeSelect this checkbox 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 checkbox is cleared.
Enable auto-import in namespace scopeSelect this checkbox 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 checkbox is selected by default.
Enable auto-import from global space

When this checkbox is selected, IntelliJ IDEA automatically adds use statements for classes, functions, and constants from the global namespace, for example, Exception, is_array(), strlen() etc.
When this checkbox is cleared, no use statement for such classes, functions, and constants is added. By default, the referenced symbol is not prepended with a backslash. To have a backslash inserted automatically, select the Prepend functions and constants from the global space with '\' checkbox.

Prepend functions and constants from the global space with '\'The checkbox is available only when the Enable auto-import from global space is cleared. When the checkbox is selected, IntelliJ IDEA automatically prepends called functions and referenced constants from the global namespace with a backslash.
When the checkbox is cleared, no backslashes are added.
To keep your code easy to read and increase productivity by avoiding additional loops during name resolution, select either the Enable auto-import from global space or the Prepend functions and constants from the global space with '\' checkbox. See PHP name resolution rules for more details.
Last modified: 4 April 2018