Where are the recorded macros stored in Notepad++?
Asked Answered
S

8

145

I have recorded a macro that I want to share with my work colleague.

In what location are these recorded macros saved, so that I can add it to his machine?

If interested, the macro is for taking a list of values and adding quotes and comma so that it can be used in the WHERE clause of of an SQL query (WHERE x IN ('value1','value2','value3')).

Setiform answered 25/3, 2011 at 11:45 Comment(2)
Wow... I came up with a macro that does exactly that and wanted to export it for almost the same reason and found your post. Goes to show how much of what programmers do is re-inventing the wheel :/ would be nice if notepad++ has a community for sharing macros.Ziagos
For those looking to actually program macros (in python): npppythonscript.sourceforge.net (available as a plugin from within notepad++'s plugin manager)Ariellearies
R
168

In Windows the macros are saved at %AppData%\Notepad++\shortcuts.xml (Windows logo key + E and copy&paste %AppData%\Notepad++\)

Or:

  • In Windows < 7 (including Win2008/R2) the macros are saved at C:\Documents and Settings\%username%\Application Data\Notepad++\shortcuts.xml
  • In Windows 7|8|10 C:\Users\%username%\AppData\Roaming\Notepad++\shortcuts.xml

Note: You will need to close Notepad++ if you have any new macros you want to 'export'.


Here is an example:

<NotepadPlus>
    <InternalCommands />
    <Macros>
        <Macro name="Trim Trailing and save" Ctrl="no" Alt="yes" Shift="yes" Key="83">
            <Action type="2" message="0" wParam="42024" lParam="0" sParam="" />
            <Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
        </Macro>
        <Macro name="abc" Ctrl="no" Alt="no" Shift="no" Key="0">
            <Action type="1" message="2170" wParam="0" lParam="0" sParam="a" />
            <Action type="1" message="2170" wParam="0" lParam="0" sParam="b" />
            <Action type="1" message="2170" wParam="0" lParam="0" sParam="c" />
        </Macro>
    </Macros>
    <UserDefinedCommands>....

I added the 'abc' macro as a proof-of-concept.

Rotative answered 25/3, 2011 at 12:44 Comment(7)
I had to close and open notepad++ again to see the changes in the files for a macro I just recorded.Manometer
By the way, you can use %username% instead of [username] and it works automatically when pasted to explorer's address bar.Milklivered
I found that I had to edit the shortcuts.xml in a different editor otherwise Notepad++ just overwrote my changes when I closed it... Also you can use %appdata% in Explorers address bar to get straight into the Roaming or Application Data directories.Total
yes, edit it in another text editor, otherwise Notepad++ keeps overwriting it.Vertumnus
It's possible to merge several macro in one (the operation will be done one after the other). It's very intuitive: just remove the end macro tags after the first one + the tags introducing the second one, (only the first macro will appear on notepad++). Launch it, and it will launch the operation of the first + the operation of the second macro that has been added to the end of the first). (@Zhaph, I did edit my macro using notepad++, no problem)Choler
If you use the AppData environment variable, you can specify a single path which will be valid on all versions of Windows, both old and new; %AppData%\Notepad++\shortcuts.xmlMetzgar
Note: Newly added macros won't reflect until you close Notepad++Ironware
B
39

For Windows 7 macros are stored at C:\Users\Username\AppData\Roaming\Notepad++\shortcuts.xml.

Brakeman answered 23/6, 2011 at 9:56 Comment(2)
Just deleted some old macros and made a new macro. For me the macros where saved or deleted to shortcuts.xml first after saving any/random file in Notepad++, took a while to figure it out.Capel
Or just use this, which will work in all cases: %APPDATA%\Notepad++\shortcuts.xmlTergum
C
5

Hit F6

Insert::

npp_open $(PLUGINS_CONFIG_DIR)\..\..\shortcuts.xml

Click OK

You now have the file opened in your editor.


Before altering things checkout the related docs:

Charie answered 30/10, 2012 at 15:24 Comment(3)
The contents of a macro definition can be edited only in the shortcuts.xml file: there is no built-in interface in Notepad++. For more information on the details of how the macros are stored, and the syntax involved, see the Configuration Files Details: section.Gwendolyn
What does [F6] mean to you? In my configuration it does nothing.Madison
@Madison It looks like they may be using the NppExec plugi - github.com/d0vgan/nppexecDuaneduarchy
H
4

On Vista with virtualization on, the file is here. Note that the AppData folder is hidden. Either show hidden folders, or go straight to it by typing %AppData% in the address bar of Windows Explorer.

C:\Users\[user]\AppData\Roaming\Notepad++\shortcuts.xml
Hondo answered 29/10, 2012 at 18:6 Comment(0)
G
3

You can find the shortcuts.xml in AppData\Roaming\Notepad++\ path only when using the default settings. If you have backup configured, you can find and set the path in Preferences -> Backup -> Backup path.

When these settings are applied, files in AppData directory won't be used.

Goldschmidt answered 3/12, 2014 at 18:10 Comment(0)
O
1

If you install Notepad++ on Linux system by wine (In my case desktop Ubuntu 14.04-LTS_X64) the file "shortcuts.xml" is under :

$/home/[USER-NAME]/.wine/drive_c/users/[USER-NAME]/My Documents/.wine/drive_c/Program Files (x86)/Notepad++/shortcuts.xml

Thanks to Harrison and all that have suggestions for that isssue.

Overdevelop answered 14/9, 2014 at 7:28 Comment(0)
L
1

Notepad++ will forget your macros unless you map them to hotkeys via Settings - Shortcut mapper - Macros before exiting Notepad++ (as per https://superuser.com/questions/332481/how-can-i-add-a-macro-in-notepad. Tested with Notepad v6.8.3 on Windows7.)

Lollis answered 5/10, 2015 at 3:4 Comment(0)
P
0

Go to %appdata%\Notepad++ folder.

The macro definitions are held in shortcuts.xml inside the <Macros> tag. You can copy the whole file, or copy the tag and paste it into shortcuts.xml at the other location.
In the latter case, be sure to use another editor, since N++ overwrites shortcuts.xml on exit.

Pilose answered 18/1, 2016 at 13:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.