## How to edit or modify a Notepad++ macro

orish
2013-05-29
2015-04-02
• orish - 2013-05-29

Hi - I've seen discussions about where to find the macro file (shortcuts.xml) in various locations - at least in Windows.

But I still can't figure out how to modify a macro that I've recorded. I made a number of finds & replaces, but then I need to modify what needs to be replaced. (It was a long session of dozens of replaces, so I'm not sure I can go through it all over again, and possibly make other mistakes!)

All I see in the shortcuts.xml file are lines like:

```    <Action type="3" message="1625" wParam="0" lParam="1" sParam="" />
<Action type="3" message="1702" wParam="0" lParam="768" sParam="" />
<Action type="3" message="1701" wParam="0" lParam="1" sParam="" />
<Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
<Action type="3" message="1601" wParam="0" lParam="0" sParam="&lt;h1&gt;&lt;a*&gt;&lt;/a&gt;"
```

So I presume there is some other file that stores the search strings for 1625, 1702, 1701, etc.

Is there a simpler way to modify the search & replace macros, perhaps using a macro editor that can work with Notepad++ macros directly?

• Tom Mahon - 2013-06-11

It takes several <Action ...=""> lines to make one command. "1700" is the start, "1601" specifies the search pattern, "1625" specifies the search type (extended in your case), "1702" specifies the search parameters (512 = search direction downwards, 256 = wrap search), then "1701" is the actual command (search in your case).
You have to be careful to make your changes to a backup file because when you exit Notepad++ (to make the changes take effect) it will overlay shortcuts.xml with whatever its macro buffer will have, wiping out your changes. So after making your changes: exit, copy the backup file onto shortcuts.xml, then restart Notepad++.
Hope this helps.

• T. Bug Reporter - 2015-03-07

The list of codes for Notepad++ macros is at: [unhelpful URL redacted]

This information has apparently been moved; can anyone supply a current URL?

• THEVENOT Guy - 2015-03-11

Hello orish, Tom Mahon and T Bug Reporter,

Some infos about building a search/replacement macro, in the shortcuts.xml file :-)

• Close any opened instance of Notepad++

• Open the shortcuts.xml file, with an OTHER editor than N++ ( Notepad, Wordpad, Word...)

• Inside the Macros section, the general form, of a search/replacement macro, should be :

```<Macro name="Search/Replacement Test" Ctrl="yes" Alt="no" Shift="no" Key="...">

<Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
<Action type="3" message="1601" wParam="0" lParam="0" sParam="STRING TO SEARCH" />
<Action type="3" message="1625" wParam="0" lParam="SEARCH MODE" sParam="" />
<Action type="3" message="1602" wParam="0" lParam="0" sParam="REPLACEMENT STRING" />
<Action type="3" message="1653" wParam="0" lParam="0" sParam="SEARCH PATH DIRECTORY" />
<Action type="3" message="1652" wParam="0" lParam="0" sParam="FILE FILTERS" />
<Action type="3" message="1702" wParam="0" lParam="OPTIONS NUMBER" sParam="" />
<Action type="3" message="1701" wParam="0" lParam="COMMAND NUMBER" sParam="" />

</Macro>
```

See the complete description of these different actions, on the N++ wiki, at the address :

IMPORTANT :

• The Path must always end with an antislash character (\)

• The weight 512, of the options number, means, actually, "Search goes downwards" ( and NOT upwards )

Remarks :

• The Find All in Current Document action ( 1641) doesn't seem to work, as the Search Result dialog is empty ! Instead, you may use the Find All action ( 1636 ), which, of course, will perform the search, on all files currently opened !

• If you use the Count action ( 1614 ), the Search/Replacement dialog must be previously opened to display the number of occurrences, at the bottom of the S/R windows.

Cheers,

guy038

Last edit: THEVENOT Guy 2015-03-22
• Timothy Suhr - 2015-04-02

Were are the recorded macros stored? Does not appear to be in the shortcuts.xml

Thanks!

Last edit: Timothy Suhr 2015-04-02