Where is the user macro file?
-
It depends.
- Normal installation:
%AppData%\Notepad++\shortcuts.xml
– if you paste that path into Windows explorer, it will go to the right directory. 🛈 - Cloud: if you have Settings > Preferences > Cloud enabled, the
shortcuts.xml
will go in whatever folder you have defined in that dialog - Portable / “Local Config Mode”: if you have a portable Notepad++ (unzipped a .zip/.7z, rather than installed Notepad++), it will be in the same folder as the notepad++.exe executable.
If you look at your ? menu’s Debug Info, you can see whether it says
Local Conf mode: ON
orOFF
. . For example, mine showsON
because I use portable:
- official config file docs: https://npp-user-manual.org/docs/config-files/
- Normal installation:
-
@PeterJones said in Where is the user macro file?:
- Portable / “Local Config Mode”: if you have a portable Notepad++ (unzipped a .zip/.7z, rather than installed Notepad++), it will be in the same folder as the notepad++.exe executable.
Just to augment what @PeterJones said for number 3:
If you have a
doLocalConf.xml
file (usually a zero-length file, but probably does not matter) in the same folder as yournotepad++.exe
, then I believe that trumps everything else and yourshortcuts.xml
and some other config files will be located right in that same folder.Peter, I don’t know that info currently in the manual is anywhere close to as good as what you (and possibly I, if you agree) have said in this thread.
-
@Alan-Kilborn said in Where is the user macro file?:
Peter, I don’t know that info currently in the manual is anywhere close to as good as what you (and possibly I, if you agree) have said in this thread.
Yep: usermanual issue #139 created and assigned to me.
-
@PeterJones said in Where is the user macro file?:
%AppData%\Notepad++\
Thanks guys, I found it in the AppData folder (I had to unhide it). So there are two shortcuts.xml files, one in the Notepad++ file, and a second one for my own macros. Yes, the manual does not mention this second one, which is what confused me! Now to learn the macro language so I can go in and edit… on first glance it seems like a very wordy macro language, with a line per character.
-
This post is deleted! -
@Harry-Goldhagen said in Where is the user macro file?:
so I can go in and edit
Probably it is best to attempt to record most of what you want to do, and have Notepad++ write it for you. Then, augment with any hand-edits things the recorder won’t do (it isn’t perfect, and won’t record all actions).
with a line per character
Do you mean to type a character into a document? If so, then yes, but in practice macros don’t really do a lot of that, or at least MY macros don’t. Maybe yours will? Don’t know what you have in mind.
If you really want to dive into macros, you’ll want to obtain the menuCmdID.h file from the source code. This will help you decode/encode lines like these in
shortcuts.xml
:<Macro name="Trim Trailing Space and Save" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="2" message="0" wParam="42024" lParam="0" sParam="" /> <Action type="2" message="0" wParam="41006" lParam="0" sParam="" /> </Macro>
…meaning what 42024 and 41006 are.
Also, the section at the very bottom of THIS PAGE in the documentation (entitled “Searching actions when recorded as macros”) will help you understand how find-related macros are done. @PeterJones Any way to link more directly to that section?
All that being said:
Don’t get too excited about the macro feature.
If you do you will probably be disappointed.
You may want to turn to scripting which can do soooo much more. -
@Alan-Kilborn said in Where is the user macro file?:
@Harry-Goldhagen said in Where is the user macro file?:
with a line per character
Do you mean to type a character into a document? If so, then yes, but in practice macros don’t really do a lot of that, or at least MY macros don’t. Maybe yours will? Don’t know what you have in mind.
Just some background: the reason the macro recorder does one line per character is the recorder is basically tracking “keystrokes” (clicks / menu commands / search dialog buttons / etc). Those same “typing” macro commands can and do allow strings of more than one character; it’s just the recorder cannot know that it’s going to be a longer “string”, so just records one character per action.
If you really want to dive into macros, you’ll want to obtain the menuCmdID.h file from the source code. This will help you decode/encode lines like these in
shortcuts.xml
:Yeah, so
menuCmdID.h
has the type-2 actions.Scintilla.iface
has the type-0 and type-1 action IDs. This is mentioned in the official docs in the<Macros>
section of the Config File Details (https://npp-user-manual.org/docs/config-files/#macros)Also, the section at the very bottom of THIS PAGE in the documentation (entitled “Searching actions when recorded as macros”) will help you understand how find-related macros are done. @PeterJones Any way to link more directly to that section?
https://npp-user-manual.org/docs/searching/#searching-actions-when-recorded-as-macros
Oh, right, and something else to add to the docs: I need to link in the FindReplaceDlg_rc.h as the location for all those 1700 and similar “magic numbers” in the searching-actions.
In some browsers, the TOC for the individual page will show up, and the links there have the anchors for each header available. Unfortunately, the magic CSS that knows when you’re on a mobile browser will often hide that TOC.
All that being said:
Don’t get too excited about the macro feature.
If you do you will probably be disappointed.
You may want to turn to scripting which can do soooo much more.To put it differently: macros are good for sequential actions with no decision-making. For anything else, use a scripting plugin.
-
Hello, @harry-goldhagen, @peterjones, @alan-kilborn and All,
@harry-goldhagen said :
on first glance it seems like a very wordy macro language, with a line per character.
This sentence caught my attention ! I said to myself: could we put several characters, together, in the same
2170
instruction ?
For instance this simple text :
Test Second line !
will normally be recorded as :
<Macro name="Test" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="1" message="2170" wParam="0" lParam="0" sParam="T" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="e" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="s" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="t" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="
" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="
" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="S" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="e" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="c" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="o" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="n" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="d" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam=" " /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="l" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="i" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="n" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="e" /> <Action type="1" message="2170" wParam="0" lParam="0" sParam=" " /> <Action type="1" message="2170" wParam="0" lParam="0" sParam="!" /> </Macro>
So, I tried to cut down all this stuff with this version :
<Macro name="Test_1" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="1" message="2170" wParam="0" lParam="0" sParam="Test
Second line !" /> </Macro>
And guess what ? It works nicely and this text is kept over N++ sessions, without any problem !
Note that it works with a very long sentence, too, as in this second test with the Preamble of the N++
license.txt
file :<Macro name="Test_2" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="1" message="2170" wParam="0" lParam="0" sParam="The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too." /> </Macro>
So, one more thing to remember !
Alan, Peter, I hope that, this time, I don’t relay false news about the configuration file
shortcuts.xml
. Just experiment my assumption !Best Regards
guy038
P.S. :
Very hard to type this message because my pussy has just settled between my keyboard and me ;-)) The naughty one !
-
@guy038 Thanks everyone, lots to learn now! I’m just trying to simply automate web page creation for my static site.
-
@PeterJones I’m unfamiliar with scripting, is this also described in the manual? I have no programming skills, I only use Notepad++ for writing web pages and CSS files, so I’m hoping scripting is a straightforward feature…
-
@Harry-Goldhagen said in Where is the user macro file?:
I’m unfamiliar with scripting, is this also described in the manual? I have no programming skills, I only use Notepad++ for writing web pages and CSS files, so I’m hoping scripting is a straightforward feature…
Because scripting is done with a plugin, it wouldn’t be in the N++ manual.
If you have “no programming skills”, probably best to stay away from scripting. Unless you have a burning desire to acquire some of those skills.
-
@Alan-Kilborn Thanks, looks like I’ll stick to macros! By the way, I must say this is one of the most helpful forums I’ve ever used! The NPP crowd is very helpful. Glad a friend of mine recommended that I use it for html coding.
-
@Harry-Goldhagen said in Where is the user macro file?:
Glad a friend of mine recommended that I use it for html coding.
Just don’t ask your HTML coding questions here!
We don’t take kindly to that!
:-) -
@PeterJones said in Where is the user macro file?:
@Alan-Kilborn said in Where is the user macro file?:
Peter, I don’t know that info currently in the manual is anywhere close to as good as what you (and possibly I, if you agree) have said in this thread.
Yep: usermanual issue #139 created and assigned to me.
Pull Request #140 submitted.
( @Alan-Kilborn , during my investigation, I confirmed that cloud actually beats doLocalConf, rather than the other way around as you phrased it.)
-
@PeterJones said in Where is the user macro file?:
I confirmed that cloud actually beats doLocalConf, rather than the other way around as you phrased it.
Interesting.
It seems like the xml file should beat everything else, but I guess not.
At least it is documented well now.
Thanks to your efforts. -
More upcoming work for Peter on this: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/9287
:-(
-
@Alan-Kilborn said in Where is the user macro file?:
:-(
It’s only going to be another sentence or two. Not a killer addition. ;-)
created usermanual issue #141
-
Hello,@Harry-Goldhagen
In Windows, the macros are saved at %AppData%\Notepad++\shortcuts.XMLOr
In Windows < 7 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’.I hope this information will be useful to you.
Thank you.