# Auto Import

## XML

| Show auto-import tooltip |  Automatically show an auto-import tooltip when typing the name of an unbound namespace.  For more information, refer to [importing unbound namespaces](working-with-xml.html#import-xml-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:     Always: 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.     Never: no import statements will be added, you won't be asked about unresolved references.    |
| Show auto-import tooltip for | Select whether you want the IDE to show popups for Classes and Static methods and fields. By default, both options are selected.  |
| Optimize imports on the fly | If 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 fly | This option enables automatic insertion of import statements if there's only one source of import. |
|  Include auto-import of static members in completion |      This option allows you to import frequently used static methods automatically. When you type a method from a prioritized class, the IDE shows completion suggestions. Selecting a suggestion from the list inserts the corresponding import statement without requiring manual edits.       You can exclude some members that should never be added to static imports, such as `of`, `valueOf`, and so on. To do so, use `-`, for example:        ```GENERIC -java.util.Objects.requireNonNull ```      Learn more from [Prioritize classes for auto-import](creating-and-optimizing-imports.html#prioritize-classes-in-auto-import).    |
| Exclude from auto-import and completion | Specify 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

> **Note:**
> Auto-import works only for the ECMAScript 6 language level. For more information, refer to [Choosing the JavaScript language version](javascript-specific-guidelines.html#ws_js_choose_language_version).

|    Add ES6 imports on code completion    |      * 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 ![Add ES6 imports on code completion](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_es6_auto-import_1200.animated.gif)    * When the checkbox is cleared, on pressing `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Alt+Enter` (NetBeans), `Alt+Enter` (Visual Studio), `⌥ ⏎` (Visual Studio (macOS)), `Ctrl+1` (Eclipse), `⌘ 1` (Eclipse (macOS)) IntelliJ IDEA shows a popup that suggests importing the symbol ![Add ES6 imports on code completion disabled](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_es6_autoimport_off_1200.png)    * 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 ![Completion for imports in React stateless components ](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_import-react-stateless.animated.gif)    |
| Add TypeScript imports automatically |     Select this checkbox if you want IntelliJ IDEA to generate import statements in TypeScript code. Use the checkboxes below to choose when import generation will be invoked.        * On code completion 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    * With auto-import tooltip If this checkbox is selected, IntelliJ IDEA shows a tooltip with an import suggestion when you place the caret at an unresolved symbol that can be imported. When the checkbox is cleared, you can invoke import generation only be pressing `Alt+Enter` (Windows), `⌥ ⏎` (macOS), `⌥ ⏎` (IntelliJ IDEA Classic (macOS)), `⌥ ⏎` (macOS System Shortcuts), `Alt+Enter` (XWin), `Alt+Enter` (GNOME), `Alt+Enter` (KDE), `Alt+Enter` (Emacs), `Alt+Enter` (Sublime Text), `⌥ ⏎` (Sublime Text (macOS)), `Alt+Enter` (NetBeans), `Alt+Enter` (Visual Studio), `⌥ ⏎` (Visual Studio (macOS)), `Ctrl+1` (Eclipse), `⌘ 1` (Eclipse (macOS)).    * Unambiguous imports on the fly With this checkbox selected, IntelliJ IDEA adds import statements when you type your code or paste a fragment with a symbol that is not yet imported if there is only one source to import the symbol from.    |

When you are using ES6 modules in a browser that requires full file names, for example, in Chrome, it is important that the names of ES6 modules in import statements have the `.js` extensions.

* To add the extension automatically in the JavaScript context, select the Use file extension checkbox on the [Imports tab](settings-code-style-javascript.html#ws_js_settings_editor_code_style_imports_tab) of the Code Style: JavaScript page.

* To add the extension automatically in the TypeScript context, select the Use file extension checkbox on the [Imports tab](null) of the Code Style: TypeScript page.

## JSP

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

## Scala

|    > **Note:** > This table is only available when Scala plugin is downloaded and installed.   The Scala plugin is not bundled with IntelliJ IDEA, but it can be installed on the Settings \| Plugins page, tab Marketplace, as described in [Installing plugins from JetBrains Marketplace](managing-plugins.html#install_plugin_from_repo).    |
| Insert imports on paste |    Select how IntelliJ IDEA should process references to missing classes in pasted blocks of code:      Always: 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.       Never: no import statements will be added, you won't be asked about unresolved references.     |
| Show import popup for: | You can control the display of the import popups and disable them for the following code elements:       * Classes    * Static members    * Implicit conversions    * Implicit definitions    |
| Add unambiguous imports on the fly | This option enables automatic insertion of import statements if there's only one source of import.  |
| Optimize imports on the fly | If this option is on, IntelliJ IDEA [removes                         unused imports,                         adds missing imports, and organizes import statements](creating-and-optimizing-imports.html#optimize-imports) silently as you work in the editor.  |

## PHP

|    > **Note:** > This table is only available when PHP plugin is downloaded and installed.   The PHP plugin is not bundled with IntelliJ IDEA, but it can be installed on the Settings \| Plugins page, tab Marketplace, as described in [Installing plugins from JetBrains Marketplace](managing-plugins.html#install_plugin_from_repo).    |
| Insert imports on paste |    Select how IntelliJ IDEA should process references to missing classes and methods in pasted blocks of code:        * All: import statements will be added automatically for all missing classes and methods found in pasted blocks of code.    * Ask: IntelliJ IDEA will prompt you to select which classes and methods you want to import. If the pasted class is already referenced in the target code [via an alias](http://php.net/manual/en/language.namespaces.importing.php), IntelliJ IDEA will prompt you to reuse this alias instead of creating a new import statement. ![the Select Classes To Import dialog: reuse existing alias](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ps_reuse_alias_on_paste.png)    * None: no import statements will be added, you won't be asked about unresolved references.                           Note that adding imports on paste is only possible if the copied element is properly resolved in code (that is, not highlighted by the Undefined class or  Undefined method  inspections), and project analysis is finished.                           |
| Enable auto-import in file scope | Select this checkbox to have IntelliJ IDEA automatically import PHP namespaces, add use statements, and [complete short class names](creating-and-optimizing-imports.html) 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 scope | Select this checkbox to have IntelliJ IDEA automatically import PHP namespaces, add use statements, and [complete short class names](creating-and-optimizing-imports.html) on the fly when you are typing in a class or file that belongs to a certain namespace. The checkbox is selected by default.  |
|  Treat symbols from the global space  |     In this area, configure auto-import from the global namespace separately for classes, functions, and constants.         * Prefer FQN: If selected, IntelliJ IDEA automatically inserts the fully-qualified name of a symbol from the global namespace, prepended with a backslash, for example: ```PHP namespace A; $myException = new \Exception(); $a = \strlen("Test"); echo \PHP_EOL; ```    * Prefer Import: If selected, IntelliJ IDEA automatically adds `use` statements for symbols from the global namespace if this doesn’t result in a conflict, for example: ```PHP namespace A; use Exception; use const PHP_EOL; use function strlen; $myException = new Exception(); $a = strlen("Test"); echo PHP_EOL; ```    * Prefer Fallback: If selected, IntelliJ IDEA neither inserts a fully-qualified name of a function or a constant, nor imports them by means of the `use` statement. The [fallback](https://php.net/manual/en/language.namespaces.fallback.php) global functions or constants are preferred in this case, for example: ```PHP namespace A; use Exception; $myException = new Exception(); $a = strlen("Test"); echo PHP_EOL; ```     |

