# Advanced completion

## Type-matching completion

Smart type-matching code completion filters the suggestion list and shows only the types applicable to the current context.

Procedure: Invoke type-matching completion

* To invoke type-matching completion, start typing and press `Ctrl+Shift+Space` (Windows), `⌃ ⇧ Space` (macOS), `⌃ ⇧ Space` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ Space` (macOS System Shortcuts), `Ctrl+Shift+Space` (XWin), `Ctrl+Shift+Space` (GNOME), `Ctrl+Shift+Space` (KDE), `Ctrl+Shift+Space` (Emacs), `Ctrl+Shift+Space` (Sublime Text), `Ctrl+Shift+Space` (Sublime Text (macOS)), `⌃ ⇧ Space` (Xcode), `Ctrl+Alt+Space` (Visual Studio), `⌃ ⌥ Space` (Visual Studio (macOS)), `Ctrl+Shift+Space` (ReSharper), `⌃ ⇧ Space` (ReSharper (macOS)), `Ctrl+Shift+Space` (QtCreator), `⌃ ⇧ Space` (QtCreator (macOS)), `Ctrl+Shift+Space` (NetBeans), `Alt+Shift+Space` (Eclipse), `⌥ ⇧ Space` (Eclipse (macOS)) or  select `Code | Code Completion | Type-Matching` from the main menu.

![Smart type completion](https://resources.jetbrains.com.cn/help/img/idea/2026.2/cl_smartCompletion.png)

## Statement completion

You can create syntactically correct code constructs by using statement completion. It inserts the necessary syntax elements (parentheses, braces, and semicolons) and gets you in a position where you can start typing the next statement.

To invoke statement completion, start typing a code construct and press `Ctrl+Shift+Enter` (Windows), `⌘ ⇧ ⏎` (macOS), `⌘ ⇧ ⏎` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ ⏎` (macOS System Shortcuts), `Ctrl+Shift+Enter` (XWin), `Ctrl+Shift+Enter` (GNOME), `Ctrl+Shift+Enter` (KDE), `Ctrl+Shift+Enter` (Emacs), `Ctrl+Shift+Enter` (Sublime Text), `Ctrl+Shift+Enter` (Sublime Text (macOS)), `⌘ ⇧ ⏎` (Xcode), `Ctrl+Shift+Enter` (Visual Studio), `⌘ ⇧ ⏎` (Visual Studio (macOS)), `Ctrl+Shift+Enter` (ReSharper), `⌘ ⇧ ⏎` (ReSharper (macOS)), `Ctrl+Shift+Enter` (QtCreator), `Ctrl+Shift+Enter` (QtCreator (macOS)), `Ctrl+Shift+Enter` (NetBeans), `Ctrl+Shift+Enter` (Eclipse), `⌘ ⇧ ⏎` (Eclipse (macOS)).

Complete Statement works with the following language constructs:

* Type and type members: classes, namespaces, and enums.

* Statements: `if/else`, `while`, `do`, `for`, `switch/case`, `try/catch`.

Procedure: Complete a function declaration

* Start typing a function declaration and press `Ctrl+Shift+Enter` (Windows), `⌘ ⇧ ⏎` (macOS), `⌘ ⇧ ⏎` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ ⏎` (macOS System Shortcuts), `Ctrl+Shift+Enter` (XWin), `Ctrl+Shift+Enter` (GNOME), `Ctrl+Shift+Enter` (KDE), `Ctrl+Shift+Enter` (Emacs), `Ctrl+Shift+Enter` (Sublime Text), `Ctrl+Shift+Enter` (Sublime Text (macOS)), `⌘ ⇧ ⏎` (Xcode), `Ctrl+Shift+Enter` (Visual Studio), `⌘ ⇧ ⏎` (Visual Studio (macOS)), `Ctrl+Shift+Enter` (ReSharper), `⌘ ⇧ ⏎` (ReSharper (macOS)), `Ctrl+Shift+Enter` (QtCreator), `Ctrl+Shift+Enter` (QtCreator (macOS)), `Ctrl+Shift+Enter` (NetBeans), `Ctrl+Shift+Enter` (Eclipse), `⌘ ⇧ ⏎` (Eclipse (macOS)) after the parenthesis.

| Before Complete Statement | After Complete Statement |
| --- | --- |
|     ```CPLUSPLUS void myFunc(/*caret*/ ```    |     ```CPLUSPLUS void myFunc();/*caret*/ ```    |

Procedure: Complete a code construct

* Start typing a code construct and press `Ctrl+Shift+Enter` (Windows), `⌘ ⇧ ⏎` (macOS), `⌘ ⇧ ⏎` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ ⏎` (macOS System Shortcuts), `Ctrl+Shift+Enter` (XWin), `Ctrl+Shift+Enter` (GNOME), `Ctrl+Shift+Enter` (KDE), `Ctrl+Shift+Enter` (Emacs), `Ctrl+Shift+Enter` (Sublime Text), `Ctrl+Shift+Enter` (Sublime Text (macOS)), `⌘ ⇧ ⏎` (Xcode), `Ctrl+Shift+Enter` (Visual Studio), `⌘ ⇧ ⏎` (Visual Studio (macOS)), `Ctrl+Shift+Enter` (ReSharper), `⌘ ⇧ ⏎` (ReSharper (macOS)), `Ctrl+Shift+Enter` (QtCreator), `Ctrl+Shift+Enter` (QtCreator (macOS)), `Ctrl+Shift+Enter` (NetBeans), `Ctrl+Shift+Enter` (Eclipse), `⌘ ⇧ ⏎` (Eclipse (macOS)).

CLion automatically completes the construct and adds `end`. The caret is placed at the next editing position.

| Use case | Before Complete Statement | After Complete Statement |
| --- | --- | --- |
|  Class declaration  |     ```CPLUSPLUS class NewClass /*caret*/ ```    |     ```CPLUSPLUS class NewClass { /*caret*/ }; ```    |
|  `switch` clause  |     ```CPLUSPLUS switch/*caret*/ ```    |     ```CPLUSPLUS switch (/*caret*/) {} ```    |
|  |     ```CPLUSPLUS switch (i /*caret*/) {} ```    |     ```CPLUSPLUS switch (i) { /*caret*/ } ```    |
|  `while` statement  |     ```CPLUSPLUS while/*caret*/ ```    |     ```CPLUSPLUS while (/*caret*/) {} ```    |
|  |     ```CPLUSPLUS while (n > 0/*caret*/) {} ```    |     ```CPLUSPLUS while (n > 0) { /*caret*/ } ```    |
|  `if` statement  |     ```CPLUSPLUS if /*caret*/ ```    |     ```CPLUSPLUS if (/*caret*/) {} ```    |
|  |     ```CPLUSPLUS if (n > 0/*caret*/) {} ```    |     ```CPLUSPLUS if (n > 0) { /*caret*/ } ```    |
|  `for` statement  |     ```CPLUSPLUS for /*caret*/ ```    |     ```CPLUSPLUS for (/*caret*/) {} ```    |
|  |     ```CPLUSPLUS for (int i = 0; i < 10; ++i/*caret*/) {} ```    |     ```CPLUSPLUS for (int i = 0; < 10; ++i) { /*caret*/ } ```    |
|  Try-catch statement  |     ```CPLUSPLUS try /*caret*/ ```    |     ```CPLUSPLUS try { /*caret*/ } ```    |
|  |     ```CPLUSPLUS catch /*caret*/ ```    |     ```CPLUSPLUS catch (/*caret*/) { } ```    |
|  |     ```CPLUSPLUS catch (const std::exception/*caret*/) {} ```    |     ```CPLUSPLUS catch (const std::exception) { /*caret*/ } ```    |

## Hippie completion

Hippie completion is a completion engine that analyses your text in the visible scope and generates suggestions from the current context. It helps you complete any word from any of the currently opened files.

Procedure: Expand a string at caret to an existing word

1. Type the initial string and do one of the following:

* Press `Alt+/` (Windows), `⌥ /` (macOS), `⌥ /` (IntelliJ IDEA Classic (macOS)), `⌥ /` (macOS System Shortcuts), `Alt+/` (XWin), `Alt+/` (GNOME), `Alt+/` (KDE), `Alt+/` (Emacs), `Alt+/` (Sublime Text), `⌥ /` (Sublime Text (macOS)), `⌥ /` (Xcode), `Alt+/` (Visual Studio), `⌥ /` (Visual Studio (macOS)), `Alt+/` (ReSharper), `⌥ /` (ReSharper (macOS)), `Alt+/` (QtCreator), `⌥ /` (QtCreator (macOS)), `Ctrl+Shift+K` (NetBeans), `Alt+/` (Eclipse), `⌃ .` (Eclipse (macOS)) or choose `Code | Code Completion | Cyclic Expand Word` to search for matching words before the caret.

* Press `Alt+Shift+/` (Windows), `⌥ ⇧ /` (macOS), `⌥ ⇧ /` (IntelliJ IDEA Classic (macOS)), `⌥ ⇧ /` (macOS System Shortcuts), `Alt+Shift+/` (XWin), `Alt+Shift+/` (GNOME), `Alt+Shift+/` (KDE), `Alt+Shift+/` (Emacs), `Alt+Shift+/` (Sublime Text), `⌥ ⇧ /` (Sublime Text (macOS)), `⌥ ⇧ /` (Xcode), `Alt+Shift+/` (Visual Studio), `⌥ ⇧ /` (Visual Studio (macOS)), `Alt+Shift+/` (ReSharper), `⌥ ⇧ /` (ReSharper (macOS)), `Alt+Shift+/` (QtCreator), `⌥ ⇧ /` (QtCreator (macOS)), `Ctrl+K` (NetBeans), `Alt+Shift+/` (Eclipse), `Alt+Shift+/` (Eclipse (macOS)) or choose `Code | Code Completion | Cyclic Expand Word (Backward)` to search for matching words after the caret and in other open files.

The first suggested value appears, and the prototype is highlighted in the source code.

![Expand word](https://resources.jetbrains.com.cn/help/img/idea/2026.2/cl_expandword.png)

2. Accept the suggestion or hold the `Alt` (Windows), `Alt` (macOS), `Alt` (IntelliJ IDEA Classic (macOS)), `Alt` (macOS System Shortcuts), `Alt` (XWin), `Alt` (GNOME), `Alt` (KDE), `Alt` (Emacs), `Alt` (Sublime Text), `Alt` (Sublime Text (macOS)), `Alt` (Xcode), `Alt` (Visual Studio), `Alt` (Visual Studio (macOS)), `Alt` (ReSharper), `Alt` (ReSharper (macOS)), `Alt` (QtCreator), `Alt` (QtCreator (macOS)), `Alt` (NetBeans), `Alt` (Eclipse), `Alt` (Eclipse (macOS)) key and keep pressing `\` (Windows), `\` (macOS), `\` (IntelliJ IDEA Classic (macOS)), `\` (macOS System Shortcuts), `\` (XWin), `\` (GNOME), `\` (KDE), `\` (Emacs), `\` (Sublime Text), `\` (Sublime Text (macOS)), `\` (Xcode), `\` (Visual Studio), `\` (Visual Studio (macOS)), `\` (ReSharper), `\` (ReSharper (macOS)), `\` (QtCreator), `\` (QtCreator (macOS)), `\` (NetBeans), `\` (Eclipse), `\` (Eclipse (macOS)) until you find the word you need.

