Record a macro

Play a recorded macro

To play the macro in the buffer, select Macro > Playback or press the button. This will perform the macro once at the current position.

Save a recorded macro

To save the macro in the buffer, select Macro > Save current recorded macro… or press the toolbar button. A dialog will pop up asking for a name of the macro and the default key combination. These can later be changed (or deleted) using Macro > Modify Shortcut/Delete Macro…, which brings up the Settings > Shortcut Mapper on the Macros tab. When saved, the macro will be available in the bottom section of the Macro menu, or from the pulldown in the dialog accessed from the Macro > Run a Macro Multiple Times… menu entry.

As noted in the Configuration Files documentation, Notepad++ writes the configuration files (including the macros) when it exits, which means that after you save your macro, your new macro will not be written to the shortcuts.xml configuration file until Notepad++ exits. Thus, if you open shortcuts.xml after saving the macro but before exiting Notepad++, you will not be able to see your new macro yet.

Play a recorded macro multiple times

To play the current macro in the buffer or any saved macro once or multiple times, select Macro > Run a Macro Multiple Times… or press the button. A dialog will pop up allowing you to select what macro to perform (buffer macro or any saved macro) and how many times. You can also opt to perform the macro until the caret reaches the end of the current file (starting from its current position).

Note that if no macros are available, this menu option is greyed out, and the dialog is inaccessible.

Edit or delete an existing macro shortcut

To edit or delete an existing macro shortcut, you can use the Shortcut mapper, which displays all shortcuts of all kinds, and allows changing or removing a key binding. The interface is also available through the Macro > Modify shortcut/Delete macro… menu entry.

The contents of a macro definition can be edited only in the shortcuts.xml file: there is no built-in interface in Notepad++. For more information on the details of how the macros are stored, and the syntax involved, see the Configuration Files Details: section.

Some information on the limitations of Macros and possible workarounds can be found in the community page FAQ: Automating Notepad++.

Macro Security

Starting in v8.9.6.2, the Run menu added extra security-warning that will notify you if the shortcuts.xml was modified manually or outside of Notepad++ (if your file was customized when you upgraded from a version before this to this version or later, the notification will also be used the first time you run a saved entry from the Run menu). In v8.9.7, this protection was extended to also apply to the Macro menu. You can read more in the Config Files > shortucts.xml Security section; but in brief, open shortcuts.xml, verify that your <UserDefinedCommands> and <Macros> entries look correct, then use Run > Validate shortcuts.xml to inform Notepad++ that everything looks reasonable. (This security step prevents a malicious outside actor from overwriting your shortcuts.xml to include a malicious macro or run-menu command, by warning you when there’s an unexpected change to the file.)