# Live templates

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/go/2026.3/llms.txt).

> **TL;DR**
> Insert a live template: `Ctrl+J` (Windows), `⌘ J` (macOS), `⌘ J` (IntelliJ IDEA Classic (macOS)), `⌘ J` (macOS System Shortcuts), `Ctrl+J` (XWin), `Ctrl+J` (GNOME), `Ctrl+J` (KDE), `Ctrl+J` (Emacs), `Ctrl+J` (Sublime Text), `Ctrl+J` (Sublime Text (macOS)), `Ctrl+J` (VSCode), `Ctrl+J` (VSCode (macOS))
>
>
>
> Expand a live template: `Tab` (Windows), `⇥` (macOS), `⇥` (IntelliJ IDEA Classic (macOS)), `⇥` (macOS System Shortcuts), `Tab` (XWin), `Tab` (GNOME), `Tab` (KDE), `Tab` (Emacs), `Tab` (Sublime Text), `⇥` (Sublime Text (macOS)), `Tab` (VSCode), `⇥` (VSCode (macOS))
>
>
>
> Configure: `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)) Settings | Editor | Live Templates

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

To expand a code snippet, type the corresponding template abbreviation and 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)), `Tab` (VSCode), `⇥` (VSCode (macOS)). . Keep pressing `Tab` (Windows), `⇥` (macOS), `⇥` (IntelliJ IDEA Classic (macOS)), `⇥` (macOS System Shortcuts), `Tab` (XWin), `Tab` (GNOME), `Tab` (KDE), `Tab` (Emacs), `Tab` (Sublime Text), `⇥` (Sublime Text (macOS)), `Tab` (VSCode), `⇥` (VSCode (macOS))  to jump from one [variable](template-variables.html)  in the template to the next one. Press `Shift+Tab` (Windows), `⇧ ⇥` (macOS), `⇧ ⇥` (IntelliJ IDEA Classic (macOS)), `⇧ ⇥` (macOS System Shortcuts), `Shift+Tab` (XWin), `Shift+Tab` (GNOME), `Shift+Tab` (KDE), `Shift+Tab` (Emacs), `Ctrl+[` (Sublime Text), `⌘ [` (Sublime Text (macOS)), `Ctrl+[` (VSCode), `⌘ [` (VSCode (macOS))  to move to the previous variable.

Procedure: Insert a live template

1. Place the caret at the place where you want the template to expand.

2. Type the template abbreviation and press the invocation key (usually `Tab` (Windows), `⇥` (macOS), `⇥` (IntelliJ IDEA Classic (macOS)), `⇥` (macOS System Shortcuts), `Tab` (XWin), `Tab` (GNOME), `Tab` (KDE), `Tab` (Emacs), `Tab` (Sublime Text), `⇥` (Sublime Text (macOS)), `Tab` (VSCode), `⇥` (VSCode (macOS)) by default). Alternatively, on the `Code` menu, click `Insert Live Template` `Ctrl+J` (Windows), `⌘ J` (macOS), `⌘ J` (IntelliJ IDEA Classic (macOS)), `⌘ J` (macOS System Shortcuts), `Ctrl+J` (XWin), `Ctrl+J` (GNOME), `Ctrl+J` (KDE), `Ctrl+J` (Emacs), `Ctrl+J` (Sublime Text), `Ctrl+J` (Sublime Text (macOS)), `Ctrl+J` (VSCode), `Ctrl+J` (VSCode (macOS)) to open the [suggestion list](auto-completing-code.html#completion_tips) and select the necessary template.

3. If the selected template requires user input, the corresponding field is highlighted. Type the necessary value and press `Enter` (Windows), `⏎` (macOS), `⏎` (IntelliJ IDEA Classic (macOS)), `⏎` (macOS System Shortcuts), `Enter` (XWin), `Enter` (GNOME), `Enter` (KDE), `Enter` (Emacs), `Enter` (Sublime Text), `⏎` (Sublime Text (macOS)), `Enter` (VSCode), `⏎` (VSCode (macOS)) or `Tab` (Windows), `⇥` (macOS), `⇥` (IntelliJ IDEA Classic (macOS)), `⇥` (macOS System Shortcuts), `Tab` (XWin), `Tab` (GNOME), `Tab` (KDE), `Tab` (Emacs), `Tab` (Sublime Text), `⇥` (Sublime Text (macOS)), `Tab` (VSCode), `⇥` (VSCode (macOS)) to complete input and move to the next input field. After completing all input fields, the caret moves to the end of the construct (or to the `$END$` marker if the marker is defined in the template code), and the editor returns to the regular mode of operation.

Procedure: Surround a block of code with a live template

1. Select a piece of code to be surrounded.

2. On the `Code` menu, click `Surround With` `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)), `Ctrl+Alt+J` (VSCode), `⌘ ⌥ J` (VSCode (macOS)) to open the [suggestion list](auto-completing-code.html#completion_tips) and select the necessary template.

Consider the following example of the Hello World program that is coded with Live Templates.

[Video](https://resources.jetbrains.com/help/img/idea/2026.3/go_live_templates_example.mp4)

## Types of live templates

The following types of live templates are distinguished:

* Simple templates contain only fixed plain text. When you expand a simple template, the text is automatically inserted into your source code, replacing the abbreviation. | Abbreviation | Expands to | | --- | --- | | `imp` | ```GO import ( ) ``` | | `int` | ```GO func init() { } ``` | | `main` | ```GO func main() { } ``` |

* Parameterized templates contain [variables](template-variables.html) that enable user input. When you expand a parameterized template, variables are either replaced by input fields for the user to specify manually, or calculated by GoLand automatically. | Abbreviation | Expands to | | --- | --- | | `forr` | ```GO for key, value := range collection { } ``` | | `iota` | ```GO const $NAME$ $TYPE$ = iota ``` | | `err` | ```GO if $ERR$ != nil { $END$ } ``` |

* Surround templates wrap a block of the selected code with the text specified by the user.

[Postfix code completion](postfix-code-completion.html) is similar to live templates. It transforms the current expression without selecting it.    For example, you can type `.if` after an expression to invoke the corresponding postfix completion and wrap the expression with an `if` statement.

## Configure live templates

To configure live templates, open  the Editor | Live Templates settings page `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS)) . On the Live Templates page, you can see all the available live templates, enable and disable them using checkboxes, edit existing templates, and [create new
ones](creating-and-editing-live-templates.html).

Templates are grouped according to the context where they can be used (usually, by the corresponding language).   To move a template to another group, right-click the template, select Move, and then select the necessary group name.

Each live template is defined by an abbreviation containing alphanumeric characters, dots, and hyphens. The abbreviation must be unique within a group, but the same abbreviation may be used in different groups and expand to different constructs according to the context of the corresponding group . Abbreviations of modified default templates are shown in the list with blue font.

Procedure: Restore a modified template to the default settings

* On the [Live Templates](settings-live-templates.html)   page of the Settings dialog, right-click the template which you want to restore and click Restore defaults.

