# Macros

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

Macros provide a convenient way to automate repetitive procedures you do frequently while writing code. You can record, edit, and play back macros, assign shortcuts to them, and share them.

* Macros can be used to combine a sequence of editor-related actions within a file.

* You can't record button clicks, navigating to popups, and accessing tool windows, menus, and dialogs.

A temporary macro can be used without a name. For permanent macros, assign unique names.

Procedure: Record a macro

1. In the main menu, go to `Edit | Macros | Start Macro Recording`.

2. Perform necessary actions that you want to be recorded.

3. Select `Edit | Macros | Stop Macro Recording`.

4. In the Enter Macro Name dialog, specify the name for the new macro and click OK.

If the macro is intended for temporary use only, you can leave the name blank.

Procedure: Play back a macro

* To play back a temporary macro, select `Edit | Macros | Play Back Last Macro`.

* To play back a named macro, select `Edit | Macros` and  click the necessary macro name.

Procedure: Edit macros

* Select `Edit | Macros | Edit Macros`.

The left side of the dialog shows a list of available macros with the following buttons:

![the Remove button](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.remove.svg)
: Remove the selected macro.

![the Edit button](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.edit.svg)
: Edit the name of the selected macro.

The right side of the dialog shows a list of actions in the selected macro with the following button:

![the Remove button](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.remove.svg)
: Remove the selected action from the macro.

Procedure: Bind a keyboard shortcut to a macro

1. Press `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)) to open settings and then select `Keymap`.

2. Create a new keymap or select an existing keymap from the list of keymaps.

3. Expand the Macros node and select the macro for which you want to [create a keyboard shortcut](configuring-keyboard-and-mouse-shortcuts.html#add-keyboard-shortcut).

Alternatively, you can press `Ctrl+Shift+A` (Windows), `⌘ ⇧ A` (macOS), `⌘ ⇧ A` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ P` (macOS System Shortcuts), `Ctrl+Shift+A` (XWin), `Ctrl+Shift+A` (GNOME), `Ctrl+Shift+A` (KDE), `Escape, X` (Emacs), `Ctrl+Shift+P` (Sublime Text), `⌘ ⇧ P` (Sublime Text (macOS)), `Ctrl+Shift+P` (VSCode), `F1` (VSCode (macOS)) to open the Find Action… dialog, type your macro name, select it, and then press `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)), `Ctrl+.` (VSCode), `Alt+Enter` (VSCode (macOS)) to bind a shortcut.

Procedure: Share macros

If you have at least one macro recorded, you can export them along with any other settings and share them with others.

1. In the main menu, go to `File | Manage IDE Settings | Export Settings…`.

2. In the Export Settings dialog, select Macros and any other settings that you want to share.

3. Select the path for the settings archive and click OK.

Give the settings archive to someone who will import the settings and use your macros.

## Example: Combine reformatting and saving into one action

This example shows how to create a macro that [reformats the current file](reformat-and-rearrange-code.html) `Ctrl+Alt+L` (Windows), `⌘ ⌥ L` (macOS), `⌘ ⌥ L` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ L` (macOS System Shortcuts), `Ctrl+Alt+L` (XWin), `Ctrl+Alt+L` (GNOME), `Alt+Shift+L` (KDE), `Ctrl+Alt+L` (Emacs), `Ctrl+Alt+L` (Sublime Text), `⌘ ⌥ L` (Sublime Text (macOS)), `Alt+Shift+F` (VSCode), `⌥ ⇧ F` (VSCode (macOS)) and saves your project when you press `Ctrl+S` (Windows), `⌘ S` (macOS), `⌘ S` (IntelliJ IDEA Classic (macOS)), `⌘ S` (macOS System Shortcuts), `Ctrl+S` (XWin), `Ctrl+S` (GNOME), `Ctrl+S` (KDE), `Ctrl+X, Ctrl+S` (Emacs), `Ctrl+S` (Sublime Text), `⌘ S` (Sublime Text (macOS)), `Ctrl+K, S` (VSCode), `⌘ ⌥ S` (VSCode (macOS)).

1.

[Record a macro](#record-a-macro-reformat-save) with the reformat and save actions.

2.

[Bind](#bind-macro) the `Ctrl+S` (Windows), `⌘ S` (macOS), `⌘ S` (IntelliJ IDEA Classic (macOS)), `⌘ S` (macOS System Shortcuts), `Ctrl+S` (XWin), `Ctrl+S` (GNOME), `Ctrl+S` (KDE), `Ctrl+X, Ctrl+S` (Emacs), `Ctrl+S` (Sublime Text), `⌘ S` (Sublime Text (macOS)), `Ctrl+K, S` (VSCode), `⌘ ⌥ S` (VSCode (macOS)) shortcut to the created macro.

Procedure: Record the macro

1. Open any file in the editor.

2. In the main menu, go to `Edit | Macros | Start Macro Recording`.

3. Press `Ctrl+Alt+L` (Windows), `⌘ ⌥ L` (macOS), `⌘ ⌥ L` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ L` (macOS System Shortcuts), `Ctrl+Alt+L` (XWin), `Ctrl+Alt+L` (GNOME), `Alt+Shift+L` (KDE), `Ctrl+Alt+L` (Emacs), `Ctrl+Alt+L` (Sublime Text), `⌘ ⌥ L` (Sublime Text (macOS)), `Alt+Shift+F` (VSCode), `⌥ ⇧ F` (VSCode (macOS)) to reformat code (`Code | Reformat Code`) and then press `Ctrl+S` (Windows), `⌘ S` (macOS), `⌘ S` (IntelliJ IDEA Classic (macOS)), `⌘ S` (macOS System Shortcuts), `Ctrl+S` (XWin), `Ctrl+S` (GNOME), `Ctrl+S` (KDE), `Ctrl+X, Ctrl+S` (Emacs), `Ctrl+S` (Sublime Text), `⌘ S` (Sublime Text (macOS)), `Ctrl+K, S` (VSCode), `⌘ ⌥ S` (VSCode (macOS)) to save all changes (`File | Save All`). GoLand will show the performed actions in the status bar.

4. Select `Edit | Macros | Stop Macro Recording`.

5. In the Enter Macro Name dialog, specify the name for the new macro and click OK.

![go_record_a_macro_reformat_save](https://resources.jetbrains.com/help/img/idea/2026.3/go_record_a_macro_reformat_save.png)

Procedure: Assign a shortcut for the new macro

1. Press `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)) to open settings and then select `Keymap`.

2. Expand the Macros node and select the created Reformat and Save macro.

3. Right-click the macro and choose Add Keyboard Shortcut in the context menu.

![Add Keyboard Shortcut](https://resources.jetbrains.com/help/img/idea/2026.3/ij_macro_add_keyboard_shortcut.png)

4. In the Keyboard Shortcut dialog, press `Ctrl+S` (Windows), `⌘ S` (macOS), `⌘ S` (IntelliJ IDEA Classic (macOS)), `⌘ S` (macOS System Shortcuts), `Ctrl+S` (XWin), `Ctrl+S` (GNOME), `Ctrl+S` (KDE), `Ctrl+X, Ctrl+S` (Emacs), `Ctrl+S` (Sublime Text), `⌘ S` (Sublime Text (macOS)), `Ctrl+K, S` (VSCode), `⌘ ⌥ S` (VSCode (macOS)) to be used as the shortcut and click OK.

5. GoLand will warn you that the shortcut is assigned to another action. Click Remove to remove the `Ctrl+S` (Windows), `⌘ S` (macOS), `⌘ S` (IntelliJ IDEA Classic (macOS)), `⌘ S` (macOS System Shortcuts), `Ctrl+S` (XWin), `Ctrl+S` (GNOME), `Ctrl+S` (KDE), `Ctrl+X, Ctrl+S` (Emacs), `Ctrl+S` (Sublime Text), `⌘ S` (Sublime Text (macOS)), `Ctrl+K, S` (VSCode), `⌘ ⌥ S` (VSCode (macOS)) shortcut for the Save All action. You can always reassign it later if necessary.

6. Click OK to apply the changes.

Now, when you press `Ctrl+S` (Windows), `⌘ S` (macOS), `⌘ S` (IntelliJ IDEA Classic (macOS)), `⌘ S` (macOS System Shortcuts), `Ctrl+S` (XWin), `Ctrl+S` (GNOME), `Ctrl+S` (KDE), `Ctrl+X, Ctrl+S` (Emacs), `Ctrl+S` (Sublime Text), `⌘ S` (Sublime Text (macOS)), `Ctrl+K, S` (VSCode), `⌘ ⌥ S` (VSCode (macOS)), GoLand will invoke the new macro: reformat the current file and save your project.

