Skip to content

Notepad++ Macros Example

Notepad++ logo.

Do you ever find yourself doing the same things over and over and over again when working on your text files? You can save a lot of time by recording and running Notepad++ macros to automate these repetitive steps. Just record your steps once, then run them as many times as you need!

Animation showing how to record and run Notepad++ macros.

Recording and Running Notepad++ Macros

In this example, we want to transform an ordered list of names into a comma-separated list with each name inside single quotes. To do this, we will record the steps we make on one line, and then run the steps on all the remaining lines.

It would not take a lot of time to rewrite this particular list manually, but it takes a fraction of the time using macros. As with any kind of automation: the more data you work with, the more time you save 🤓

Example: Notepad++ Macros that Run on All Lines

1. Make sure that you have the Word Wrap option disabled. Notepad++ macros work on lines, and having word wrap enabled might interfere with your results.

Click View → Disable Word Wrap:

Screenshot of disabling word wrap.

2. Paste your text, and place the caret at the start of the first line. We will record our macro on this first line, so this will be the starting position.

Screenshot of placing caret at start of first line.

3. Click Start Recording. You can use either the button on the toolbar or through the menu Macro → Start Recording:

Screenshot of clicking the start recording button on the toolbar.

4. Edit the text step by step in a way that is repeatable for each line. This might require a few attempts to get right the first time, until you get used to thinking like a macro 🤖

In this example, we did the following steps:

  • Deleted the number using CTRL+Delete
  • Deleted the period and spaces using CTRL+Delete
  • Added single quote
  • Moved caret to end of line using End
  • Added single quote and comma
  • Deleted the line break using CTRL+Delete

Once you have made your edits, ensure that the caret is placed at the beginning of the next line or block of text:

Screenshot of caret at start of next text block.

5. Click Stop Recording. You can use either the button on the toolbar or through the menu Macro → Stop Recording:

Screenshot of clicking the stop recording button on the toolbar.

6. Click Playback to run your macro once. This is useful for testing. You can use either the button on the toolbar or through the menu Macro → Playback:

Screenshot of clicking the playback button on the toolbar.

7. Click Run a Macro Multiple Times to run your macro on multiple lines or until the end of the file. You can use either the button on the toolbar or through the menu Macro → Run a Macro Multiple Times:

Screenshot of running multiple times from toolbar or button.

Choose number of times to run or run until end of file:

Screenshot of selecting the option to run the macro until the end of file.

8. After running your macro, verify the results. It can help to enable Word Wrap again. In this example, we may also want to remove the trailing comma.

Click View → Enable Word Wrap:

Screenshot showing enabling word wrap again.

Tips for Recording Macros

Keep in mind that the actions will be played back exactly as they are recorded, so use CTRL to work on whole words rather than single characters:

  • Move caret to previous or next word using CTRL+arrows
  • Mark words using CTRL+SHIFT+arrows
  • Delete words using CTRL+Backspace or CTRL+Delete
  • Move caret to start or end of line using HOME and END.

Summary

Save time by using Notepad++ macros to automate repetitive steps. Record your steps once, then run them as many times as you need!

This is a very handy feature that is easy to learn and use. It has some limitations and you may have to try a few times to get it right. However, once you master Notepad++ macros, you probably won’t ever go back to manually doing the same steps over and over and over again 🤓

Share or Comment?

About the Author

Professional headshot of Cathrine Wilhelmsen.Cathrine Wilhelmsen is a Microsoft Data Platform MVP, BimlHero Certified Expert, international speaker, author, blogger, and chronic volunteer. She loves data and coding, as well as teaching and sharing knowledge - oh, and sci-fi, chocolate, coffee, and cats 🤓