可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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')
).
回答1:
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.
回答2:
For Windows 7 macros are stored at C:\Users\
Username
\AppData\Roaming\Notepad++\shortcuts.xml
.
回答3:
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
回答4:
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.
回答5:
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.
回答6:
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.)
回答7:
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.
回答8:
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.