How do I add a macro to toolbar
-
How do I add a macro to my toolbar?
-
Notepad++ does not natively allow adding new buttons to the Toolbar, without using a plugin.
The Customize Toolbar plugin will allow you to do this.
- Use Plugins > Plugins Admin to install Customize Toolbar (and restart Notepad++)
- Use Plugins > Customize Toolbar > Custom Button to enable the custom button feature
- Edit
%AppData%\Notepad++\plugins\Config\CustomizeToolbar.btn
to add the following two linesMacro,Trim Trailing Space and Save,,,*S:Tr,*S:Tr View,Show Symbol,Show All Characters,,*S:¶,*S:¶
- The first line is the way to add the macro. Just use your exact macro name instead of
Trim Trailing Space and Save
. - The second line is to overcome a bug in the plugin (the plugin isn’t actively maintained, and it started adding extra spaces when Notepad++ improved the behavior of the [¶] “Show All Characters” button)
- Note: a drawback to this is that it gets rid of Notepad++'s native icon for the action, which also includes a visible pulldown button to indicate there are options on the Toolbar:
To get the same pulldown when using the CustomizeToolbar, you have to right-click on the new icon:
- Note: a drawback to this is that it gets rid of Notepad++'s native icon for the action, which also includes a visible pulldown button to indicate there are options on the Toolbar:
- The first line is the way to add the macro. Just use your exact macro name instead of
- If you don’t like the colorful-text-as-icon provided by the Customize Toolbar for the Show All Characters, then you could follow my instructions in this reply in the bug report, which gives some example icons and shows you how to use those icons.
Similarly, if you made a .BMP file and two .ICO files for your macro, and put them in the same directory, you could use the similar method for specifying the images for the macro’s icon. An example, based on the instructions in the bug report:Macro,Trim Trailing Space and Save,,,Icons\myMacro.bmp,Icons\myMacro_light.ico,Icons\myMacro_dark.ico View,Show Symbol,Show All Characters,,Icons\allChars.bmp,Icons\allChars_off.ico,Icons\allChars_off_dark.ico
-
This method works only if the interface language is English. There are errors in another language.
-
Please reply to this topic rather than creating a new topic. I had to merge your post in to this old topic to give it context.
There are errors in another language.
Could you be more specific? What errors? Can you share the name of the macro that causes problems?
I have never had a macro with non-ASCII characters in the name, so I have no experience with it. And I don’t know how the internals of the CustomizeToolbar macro are written, so I don’t know how compatible that plugin is with non-ASCII characters. (Unfortunately, the author of that plugin doesn’t seem to be supporting it anymore, so it’s doubtful that any bugs that end up being in that plugin will be fixed. But if you give us more information, we might at least be able to come up with a workaround.)
-
CustomizeToolbar.btn needs to be a UTF-16-LE encoded file, so it can handle any Unicode character.
CustomizeToolbar.btn contains:
Macro,Äbc,,,*S:Ä,*S:Ä
shortcuts.xml contains:
<Macro name="Äbc" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="1" message="2170" wParam="0" lParam="0" sParam="Äbc" /> </Macro>
That toolbar button works for me.
But
Ä
is in the normal latin-1 range, so that might not be enough of a test.So I switched to some Cyrillic characters for the macro’s name and the text that gets typed, and the pseudo-icon on the toolbar:
CustomizeToolbar.btn contains:
Macro,АВГ,,,*S:Г,*S:Г
shortcuts.xml contains:
<Macro name="АВГ" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="1" message="2170" wParam="0" lParam="0" sParam="АВГ" /> </Macro>
After restarting, that toolbar button also works for me.
I mean, that’s not an exhaustive test, but since the Cyrillic are above codepoint 255, if it works for that, it should work for any Unicode characters.
When you open/edit
CustomizeToolbar.btn
, does the lower-right corner of the status bar have “UTF-16 Little Endian”? And if you open%AppData%\Notepad++\shortcuts.xml
, does it say “UTF-8”?Here’s a screenshot of mine for the
CustomizeToolbar.btn
file: notice the encoding in the lower-right
One thing you can try is to copy my examples, because both of those are verified as working correctly for me. So you can see if those exact setups work for you, as well.
If mine works for you, but yours do not, then using the
</>
button when making your reply, if you can paste in your exactCustomizeToolbar.btn
andshortcuts.xml
macro that’s giving you trouble, that would be really helpful to help us help you. -
@PeterJones
In English isk OK
In German
and second icon
-
Okay, now I understand.
In the
CustomizeToolbar.btn
, the menu-entry names must match your localization – the names must match what you see in your GUISo it’s not
Macro
, it’sMakros
(but the “Trim Trailing Space and Save” isn’t translated, because it’s not translated in yourMacros
menu, either)And, because it’s not View > Show Symbol > Show All Characters when the localization is set to German, you have to use the translated strings
So with the
CustomizeToolbar.btn
defining those two buttons asAnsicht,Symbole anzeigen,Alle Zeichen anzeigen,,*S:¶,*S:¶ Makros,Trim Trailing Space and Save,,,*S:Tr,*S:Tr
and restart Notepad++, the buttons work right again:
To reiterate: the text you enter in the
CustomizeToolbar.btn
must match the text you see in the menus in your localization of Notepad++. -
@PeterJones
Thanks, I understand