npp-user-manual : Recording some of your actions you perform while editing a document, and replaying those later on to avoid having to repeat that sequence of actions

Introduction

Notepad++ Macros are a really great feature if you are editing a document with repeated actions. Notepad++ can record those actions and you can run or automate those actions until your repeated task is done. Even you can save actions and you can do it later.

Let us see how to do that

Recording Macro

To record a repeated actions, you need to know what are the repeated actions performed.

  1. Let's take a scenario, here we have a list of names. We want to convert it into a JSON array.

npp-convert-file

  1. The first line contains 1. Liam. It has number, dot, space then name. This pattern follows in all the lines.
  2. So we can search for space by CTRL+F then we can remove the prefix by pressing SHIFT+HOME, BACKSPACE.
  3. Now we extracted the exact name we want. Now add double quotes and go to the end of the line by pressing END.
  4. Now add another double quote and comma and goto next line first character by pressing DOWN ARROW and HOME.
  5. If we do this action throughout the file, we will get the solution for our problem.

Once we found the pattern of actions repeated,

  1. Just perform these actions once after selecting Macro -> Start Recording
  2. Once these actions completed, goto Macro -> Stop Recording

npp-macro-record

Perform Playback

Once recordings are done, we can perform these actions as many times we want. To perform,

  1. Goto Macro and select Perform Playback (CTRL+ SHIFT + P)
  2. Once selected, the second line also got changed. You can repeat it as many time you want.
  3. Also, You can specify the number of time to perform or till end of the file to perform the action by selecting Macro -> Run a macro multiple times.

npp-macro-perform

Save macro

You can save this macro for future use.

  1. You can save it by choosing Macro -> Save Current Recorded Macro.
  2. Select whatever key combination you want to perform this macro. npp-macro-save
  3. Press the key we chose during save macro.
  4. Now the save action performed.