# Live templates for C++

> **TL;DR**
> `Settings | Editor| Live templates | C++`

On this page, you can configure and create live templates for C++ code.

![Live templates for C++](https://resources.jetbrains.com.cn/help/img/idea/2026.2/cl_nova_livetemplates.png)

Use live templates to insert common constructs into your code, such as loops, conditions, declarations, or print statements .

Select the template from the list. The bottom-left pane will show the expanded stub code. Use this pane if you need to edit the template.

Table below describes the controls of the bottom-right area of the dialog:

|  |  |
| --- | --- |
|  Shortcut  |  Use this abbreviation to insert the live template. Press `Tab` (Windows), `⇥` (macOS), `⇥` (IntelliJ IDEA Classic (macOS)), `⇥` (macOS System Shortcuts), `Tab` (XWin), `Tab` (GNOME), `Tab` (KDE), `Tab` (Emacs), `Tab` (Sublime Text), `⇥` (Sublime Text (macOS)), `⇥` (Xcode), `Tab` (Visual Studio), `⇥` (Visual Studio (macOS)), `Tab` (ReSharper), `⇥` (ReSharper (macOS)), `Tab` (QtCreator), `⇥` (QtCreator (macOS)), `Tab` (NetBeans), `Tab` (Eclipse), `⇥` (Eclipse (macOS)) after you type it in the editor.  |
| Description | This field gives a brief description of each template. |
| Options | Use these checkboxes to reformat the inserted code and shorten the qualified names. |
|  Availability  |  Click this button to open the Availability configuration dialog. In this dialog, specify the context where the template will be applied.  |
|  Use in  |   Choose whether the template will be applied in code generation, the Surround With action, or both.  |
| Show in context action |  With this option enabled, the applicable template will be shown in the actions menu.  |
| Edit variables |  Click to open the dialog where you can edit the template variables.  |

Procedure: Surround a block of code with a live template

You can quickly surround a block with one of the available live templates.

1. In the editor, select the piece of code to be surrounded.

2. Press `Ctrl+Alt+J` (Windows), `⌘ ⌥ J` (macOS), `⌘ ⌥ J` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ J` (macOS System Shortcuts), `Ctrl+Alt+J` (XWin), `Ctrl+Alt+J` (GNOME), `Ctrl+Alt+J` (KDE), `Ctrl+Alt+J` (Emacs), `Ctrl+Alt+J` (Sublime Text), `⌘ ⌥ J` (Sublime Text (macOS)), `⌘ ⌥ J` (Xcode), `Ctrl+E, U` (Visual Studio), `⌘ E, U` (Visual Studio (macOS)), `Ctrl+Alt+J` (ReSharper), `⌘ ⌥ J` (ReSharper (macOS)), `Ctrl+Alt+J` (QtCreator), `⌘ ⌥ J` (QtCreator (macOS)), `Ctrl+Alt+J` (NetBeans), `Ctrl+Alt+J` (Eclipse), `⌘ ⌥ J` (Eclipse (macOS)).

3. Select the desired template from the list:

![Surround with menu](https://resources.jetbrains.com.cn/help/img/idea/2026.2/cl_nova_surroundtemplates_menu.png)

4. CLion surrounds the code with the selected template:

![Result of surrounding a block of code with a live template](https://resources.jetbrains.com.cn/help/img/idea/2026.2/cl_nova_surroundtemplates_result.png)

## See also

### How tos

[Live templates](using-live-templates.html) [Work with source code](working-with-source-code.html)

