How to create macros in Notepad++ with practical examples

Last update: 12/08/2025
Author Isaac
  • Macros record editor actions and play them back instantly to automate repetitive tasks.
  • You can manage them from the Macro menu or fine-tune them by editing the “shortcuts.xml” file.
  • Regular expressions, markers, and shortcuts make macros more powerful.
  • If you need advanced logic, consider scripting plugins like PythonScript.

Notepad++ Macro Guide

Automation saves time and reduces errors when we edit text or code repeatedly., and Notepad++ offers a simple yet powerful macro system to achieve this without programming. If you work with large volumes of content or perform the same steps over and over again, recording and playing back actions in this editor can make a difference in your daily work.

In this guide you will learn what Notepad++ macros are, how to create, save, edit, and take them a step further. with useful examples, keyboard shortcuts y Tricks practical. You'll also see common limitations, how to work around them using the "shortcuts.xml" configuration file, and some regular expression operations that increase their usefulness.

What is a macro in Notepad++?

A macro in Notepad++ is a recording of the actions you perform within the editor to play them back later whenever you want.. May include typing or deleting text, selecting, replacing, executing commands from the menu or combine several chained operations.

Its objective is to speed up repetitive tasks such as mass replacements, formatting or inserting templates., so that the steps you've already defined are faithfully repeated with a single command. It's ideal for users who don't want (or don't need) to write scripts and prefer immediate automation.

How to create macros in Notepad++ step by step

Recording a macro is straightforward and requires no technical knowledge.. Follow this sequence to create yours:

  1. Open Notepad++.
  2. Go to the Macro menu and choose “Start Recording” (default shortcut: Ctrl+Shift+R).
  3. Perform all the actions you want to automate: typing, selecting, searching and replacing, formatting, deleting lines, etc.
  4. Go back to Macro and press “Stop Recording”.
  5. To save it, select "Save Current Macro," give it a descriptive name, and assign a key combination if desired.

Once saved, the macro is available for immediate use. and you can launch it whenever you need without manually repeating the sequence of actions.

Using and playing macros

To run a saved macro, simply go to Macro and click on its name., or use the shortcut you assigned when you saved it. Notepad++ also supports playing back the last recorded macro using the corresponding shortcut.

If you need to repeat a macro several times in a row or until the end of the document, use the Macro > “Run macro multiple times…” option and specify the number of repetitions or execution until the end of the file is reached.

  How to program macros in Excel that send commands to smart devices

Manage and edit macros from the interface

Notepad++ allows you to rename, reassign shortcuts and delete macros from its integrated manager.. Go to Macro > "Modify Shortcut/Delete Macro..." (or "Edit Macros" depending on the version) and adjust names and key combinations, or delete ones you no longer use.

Please note that depending on the version of Notepad++ the exact location of some options may vary.If you don't find a command where you expect, check the submenus or the Preferences window.

Advanced Editing: The “shortcuts.xml” File

Macros and shortcuts are stored in a configuration file called "shortcuts.xml", which is located in the Notepad++ installation folder or in the user directory (typical path: %AppData%\Notepad++\).

Directly editing that XML allows you to adjust macro details and even add actions that are not recorded during recording.This technique requires care and basic XML knowledge: a formatting error can break shortcuts or render a macro unusable.

Remember that changes to "shortcuts.xml" only take effect after restarting Notepad++. Close the editor before editing the file and reopen it to load the new settings.

Plugin Limitations and How to Work Around Them

Macros record internal editor actions, but plugin commands may not be recorded., because their menu identifiers may vary depending on plugin installation and changes.

To include plugin actions within a macro, edit "shortcuts.xml" and add an action that invokes the plugin command using its menu identifier.To find out this identifier, tools like NppUISpy are very useful, as they show the number of the currently active command.

When you update, install, or uninstall plugins, these identifiers may change., so you'll need to review them and update your macro in the XML as appropriate.

Advanced example: Macro with a plugin command (Base64)

Imagine you want to automate a conversion to Base64 with a plugin like MIME ToolsThe idea is to select everything, run Base64 Encode, select again, and copy the result.

  1. Record the macro with all possible actions (the plugin call may not be recorded).
  2. Save it with a clear name and close Notepad++.
  3. Open “shortcuts.xml”, locate your macro and you will see a sequence of action items.
  4. Manually insert a “menu command” type action targeting the plugin ID (e.g., wParam with the ID given to you by NppUISpy).
  5. Save the XML and restart Notepad++ to apply the changes.

With this trick, your macros will be able to mix native operations and plugin commands., opening the door to much more powerful automations.

  Yoke, throttle, and pedal configuration in Microsoft Flight Simulator

Useful search and replace operations with Notepad++

Many automations combine macros with searches, replaces, and regular expressions.The Find > Replace box is an essential ally for this.

Replace commas with line breaks

To replace each comma with a line break, open Find > Replace (Ctrl+H), type “,” in the search field, and use “\r\n” as the replacement.. Select the appropriate mode so that Notepad++ interprets those control characters as newline and carriage return.

Remove empty lines and white spaces

From the Edit > Line Operations menu you can remove empty lines or empty lines with spaces, which quickly cleans up documents with unnecessary gaps.

If you prefer to use regular expressions, turn on regular expression mode in Find > Replace., put «^\s*» in «Find» and leave «Replace with» empty to delete empty lines and those with only spaces or tabs.

What does that expression mean: «^» indicates the start of a line, and «\s*» matches any number (including 0) of whitespace characters, such as tabs, spaces, line feeds, or carriage returns.

Mark and delete lines by criteria

If you need to filter lines by a word or pattern, use the "Mark" tab in the search box.Enter the term, select the "Mark line" box, and then go to Search > Mark > "Clear Marked Lines" to remove only the matching lines.

Autocomplete and closing HTML/XML tags

Notepad++ has configurable auto-completion in Configure > Preferences > Auto-Complete. Enable "Enable autocomplete on each input" and choose whether you want it for functions, words, or both. Also check "Hint for function parameters" if you're working with code.

For self-closing HTML/XML tags there are two ways depending on the version: Use the “html/xml close tag” option within AutoComplete or install the TextFX Characters plugin and activate “Autoclose XHTML/XML tag” from its menu.

Remember that the exact location of these options may vary between versions., so if you don't see it at first, check the Preferences sections or the Plugin Manager.

Useful keyboard shortcuts in Notepad++

Knowing shortcuts speeds up your flow as much as a macroHere's a handy compendium:

  • Ctrl-C Copy
  • Ctrl-X Cut
  • Ctrl-Z Undo
  • Ctrl-Y Redo
  • Ctrl-V Paste
  • Ctrl-A Select All
  • Ctrl-F Launch Search dialog
  • Ctrl-H Launch Search/Replace dialog
  • Ctrl-D Duplicate the current line
  • Ctrl-L Delete the current line
  • Ctrl-T Swap the position of the current line with that of the previous line
  • F3 Find Next
  • Shift-F3 Find Previous
  • Ctrl-Shift-F Search in files
  • Ctrl-F3 Find Next (volatile)
  • Ctrl-Shift-F3 Find Previous (Volatile)
  • Ctrl-Shift-I Incremental Search
  • Ctrl-S Save File
  • Ctrl-Alt-S Save As
  • Ctrl-Shift-S Save All
  • Ctrl-O Open file
  • Ctrl-N New File
  • Ctrl-F2 Add/Remove Bookmark
  • F2 Next Marker
  • Shift-F2 Go to the previous bookmark
  • Ctrl-G Launch the Go to Line dialog
  • Ctrl-W Close the current document
  • Alt-Shift-Arrows or Alt + Left Mouse Button Multi-cursor selection mode
  • F5 Launch run dialog
  • Ctrl-Space Display list of help tips
  • Alt-Space Display auto-complete list
  • Tab (multi-line selection) Insert tab or spacing (indent)
  • Shift-Tab (multiple line selection) Delete tabs or spacing (unindent)
  • Ctrl-(numpad – / +) or Ctrl + mouse wheel Zoom in/out
  • Ctrl-(numpad /) Restore original zoom size
  • F11 Switch to full screen mode
  • Ctrl-Tab Next Document
  • Ctrl-Shift-Tab Previous document
  • Ctrl-Shift-Up Move the current line up
  • Ctrl-Shift-Down Move the current line down
  • Ctrl-Alt-F Collapse current level
  • Ctrl-Alt-Shift-F Collapse current level
  • Alt-0 Fold All
  • Alt-(1~8) Collapse level (1~8)
  • Alt-Shift-0 Unfold all
  • Alt-Shift-(1~8) Uncollapse level (1~8)
  Top 5 Video Codec Packs for Windows 10 to Play All File Formats

Many of these shortcuts can be combined with macros to further increase productivity., for example, by launching a macro and then quickly navigating with bookmarks or searches.

Apply macros to multiple files

Natively, macros act on the active documentIf your sequence includes dialog box operations that offer "in all open documents," take advantage of this option when that option exists (as with some mass replacements).

To run a macro repeatedly on several files, a practical option is to combine it with global functions in the search box., or manually iterate through the tabs, launching the macro on each one. As an advanced option, you can edit "shortcuts.xml" to approximate more global behavior, although it requires precision.

Macros vs. Plugin Scripting

When automation requires complex logic, processing multiple files with conditions, or integration with other programs, you may want to consider scripting plugins like PythonScript, which allow you to write code to control the editor with complete flexibility.

For everyday use, macros cover most needs without a learning curve., and are the best starting point before investing time in more sophisticated solutions.

notepad + +
Related article:
How to Automate Tasks in Notepad++ Using Macros: A Complete Guide