I'm trying to create a macro in Notepad++ that allows me to do a few standard Search & Replaces. I can get the macro to do everything (add lines, add characters) except search and replace.

I can't find the files to edit the macro manually.

Has anyone ever succeeded creating a Macro in Notepad++ that performs Search and Replace? How?

PS: I'm not interested in other tools that can perform this - I know my way around perl, vi(m), UltraEdit, sed, awk myself - I was just wondering if Notepad++ could do this.


Yes you can, I just tried to record a new macro, did a search and replace and it successfully saved the action so when I played the macro, it did the same search and replace action.

I am not an expert at Notepad++ Macros, but I am guessing you are... I opened a random file and created a macro called test. It looked for a word called "snip" and replaced it with "blaa".

Opening up the shortcuts.xml file after closing Notepad++ reveals this new macro:

<Macro name="test" Ctrl="no" Alt="no" Shift="no" Key="0">
    <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
    <Action type="3" message="1601" wParam="0" lParam="0" sParam="snip" />
    <Action type="3" message="1625" wParam="0" lParam="0" sParam="" />
    <Action type="3" message="1602" wParam="0" lParam="0" sParam="blaa" />
    <Action type="3" message="1702" wParam="0" lParam="768" sParam="" />
    <Action type="3" message="1701" wParam="0" lParam="1608" sParam="" />

This is tested and works on my machine, I can manually modify this file and the changes get reflected and work in Notepad++.

Please note however, the shortcuts.xml file (located in your Appdata folder), only gets loaded and saved on opening/exiting Notepad++.

  • Thanks. I found the file, but recording still didn't work. I edited the file (not with N++ off course) and pasted your snipped. N++ recognized the macro but it didn't successfully replace anything - I guess it must be some unfulfilled dependency that prevents me from recording/playing. – Konerak Dec 17 '10 at 10:43
  • 1
    All I have is Notepad++ no special addons (Installed from Ninite)... Make sure you are using the latest version - but if you can't get this to work, something may be wrong with your installation. – William Hilsum Dec 17 '10 at 10:56
  • I was after a "find and replace in all documents" function and was able to successfully produce it with the sample code above, with two minor changes: the lParam "768" above became "2" and the lParam "1608" became "1635". Otherwise, it worked great! (Notepad++ 5.9.2) – Mike Feb 26 '13 at 0:00
  • I'm using v7.6 and I was able to record a macro to do search and replace. It generated the same definition in shortcuts.xml. However the macro didn't work until after I closed Notepad++ and re-opened the program. I looked the shortcuts.xml to replace what was recorded with your example, and discovered nothing new had been written to the file. Then I remembered your note about shortcuts only getting loaded and saved only when the program opens and closes. So thanks @WilliamHilsum for that super helpful tip. I might have abandoned the effort without it. – Adam Porad Dec 17 '18 at 23:21

I previously found that this didn't work for me either. But then I updated from Notepad++ 5.6.x to 5.9.8, and now I can record find-and-replacing just fine. Very nice!

Of course, manually editing shortcuts.xml after recording one is inevitable because there is no a macro editor, and you need super human concentration for recording a huge macro flawlessly. (Make sure all instances of Notepad++ are closed before editing that file.)


I too did not find any macro editor (for manipulating text) on Notepad++ (though Notepad++ provides few inbuilt functions). But now there is a plugin available for creating macros on Notepad++. This plugin is called 'Python Script' (with good documentation and samples) through which you can write any kind of macros since with this plugin, you almost have full control availble over editor and Notepad++ itself. If you have some basic knowledge on python you may start writing macros using this plugin (The documentation of this plugin itself covers some basic python syntax for beginners).

You can search & replace and perform almost any kind of operation as a macro using this plugin.

Here is the link for more information: http://npppythonscript.sourceforge.net/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.