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!
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:
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.
3. Click Start Recording. You can use either the button on the toolbar or through the menu Macro → Start Recording:
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:
5. Click Stop Recording. You can use either the button on the toolbar or through the menu Macro → Stop Recording:
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:
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:
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:
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.
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 🤓