assign the same keyboard shortcut to multiple Macros
-
I recently posted some Macro code for a useful regex-based Find/Replace All process.
As noted in the Actions documentation, if I change the 1702 message from
786to 128, the Macro only applies to whatever text I happen to select. This can be useful in some situations, so what I’d like to do is have both variations of the Macro exist for the same keyboard shortcut (i.e. apply the original Macro when nothing is selected, but apply the modified Macro when something is selected).When I have the modified Macro code listed above the original Macro code, only the modified Macro is functional. When I switch the order, the original Macro is the only one that’s functional; it applies to all text in the file, even if only a portion of it is selected. I’m guessing this happens because the 1702 message is still 786, but I can’t figure out what I would need to change this to in order to achieve the desired configuration.
Does NP++ support contextual Macros like this?
-
@mathlete2 said in assign the same keyboard shortcut to multiple Macros:
for the same keyboard shortcut (i.e. apply the original Macro when nothing is selected, but apply the modified Macro when something is selected).
Not possible this way.
Make the macro use In selection (hopefully your search action is something that supports that option), and then to affect all text, do a Ctrl+a before running the macro. -
@Alan-Kilborn yes, using the
Ctrl
+A
shortcut prior to applying the modified Macro is the same as running the original Macro. This is easier than trying to remember a separate shortcut, so it’s probably the best alternative for the time being.However, just to confirm: there currently isn’t a way of configuring NP++ to disable a specific Macro as soon as something is selected? That’s effectively what I’m trying to do, so perhaps I should have phrased the question that way.
-
@mathlete2 said in assign the same keyboard shortcut to multiple Macros:
there currently isn’t a way of configuring NP++ to disable a specific Macro as soon as something is selected?
Correct.
Macros in Notepad++ are really simple. And simple-minded.
If you want to open things up to scripting (programming), then you can do just about anything you want.