Two Questions About Shortcut Mapper
-
-
Using the excellent shortcut mapper, I defined Num+ and Num- to SCI_LINESCROLLUP/DOWN. Works fine, except those keystrokes at the same time also insert + and - symbols into the text. How can I stop the text insertion?
-
(Perhaps related to Q#1) How do I define (say) Alt-a to insert a Unicode character into the text (say ⍺ a.k.a. U+237A, lowercase Greek alpha)? I have a bunch of these I would like to define.
Great program! Thanks for any help you can provide.
-
-
except those keystrokes at the same time also insert + and - symbols into the text.
The intention for typable keys (any of the alphanumeric or punctuation) available in the shortcut mapper is that you will only assign shortcuts to those keys if there’s a non-typable modifier. So
Alt+Num+
andAlt+Num-
would work, without typing. I doubt that the developer would implement the ability to circumvent the typing of a character from the keyboard (imagine assigning a command to the shortcutb
, and never being able to type the nameBob
again!)How do I define (say) Alt-a to insert a Unicode character into the text
My recommendation would be to record a macro of you typing it in using the Windows
Alt
+NumericKeypad hex-numpad syntax (*). So- Macro > Start Recording
- Hold
Alt
, then typeNum+
then237
on the keypad thenA
, then finally releaseAlt
⇒ the ⍺ will be typed - Macro > Stop Recording
- Macro > Save Current Recorded Macro ⇒ Give it a name (like
type ⍺
) and a shortcut
Once you’ve got one, you could theoretically edit the
%AppData\Notepad++\shortcuts.xml
to copy/paste the main sequence, and just change the name and keystroke andsParam="⍺"
for each. For example, here are⍺ U+237A
andß U+00DF
asAlt+A
andAlt+B
:<Macro name="type ⍺" Ctrl="no" Alt="yes" Shift="no" Key="65"> <Action type="1" message="2170" wParam="0" lParam="0" sParam="⍺" /> </Macro> <Macro name="type ß" Ctrl="no" Alt="yes" Shift="no" Key="66"> <Action type="1" message="2170" wParam="0" lParam="0" sParam="ß" /> </Macro>
_* Note: You can enable the extended Unicode syntax by creating/setting the registry key
HKEY_Current_User/Control Panel/Input Method
to have a REG_SZ entryEnableHexNumpad
set to1
. Now any Unicode up to U+FFFD can be entered with that by using theAlt
,Num+
, and entering the hex Unicode codepoint; and any from U+10000 and above can be entered by using their two four-hex-digit surrogate codes as twoAlt+Num+
codes.say ⍺ a.k.a. U+237A, lowercase Greek alpha
Not related to your question, but I thought I’d clarify:
⍺ U+237A
looks like a lowercase Greek alpha, but is actually “APL FUNCTIONAL SYMBOL ALPHA”, and is not considered a “letter character” in Unicode, whereasα U+03B1
is the official “GREEK SMALL LETTER ALPHA”, and is considered a “letter character” in Unicode. They have different uses/meanings in Unicode, as described in the wikipedia: Digital encoding of APL symbols.(For the irony, I used
U+00DF LATIN SMALL LETTER SHARP S
instead of a beta for theAlt+B
example, above.)If you’re going to be doing lots of different Unicode characters, I would look into an alternate method of entry, rather than dozens or hundreds of shortcuts… I personally have a script for the PythonScript plugin called
pyscReplaceBackslashSequence.py
which I have mapped toAlt+\
, and if I type\u+XXXX
then hitAlt+\
, it will replace it with the appropriate Unicode character; this can be installed per the instructions in our PythonScript FAQ. -
@PeterJones said in Two Questions About Shortcut Mapper:
The intention for typable keys (any of the alphanumeric or punctuation) available in the shortcut mapper is that you will only assign shortcuts to those keys if there’s a non-typable modifier.
It seems that situations like the Num+ example should be trapped-out if a modifier isn’t added to the combination. Or, the “Num-x” commands should be an exception to the no-modifiers rule naturally, because there is always a way to get the character they represent, without the numeric keypad being involved.
FWIW, I tried assigning the “Open containing folder in Explorer” command to the barebones Num+, and it worked to run Explorer without also putting a
+
in the document. -
@Alan-Kilborn said in Two Questions About Shortcut Mapper:
FWIW, I tried assigning the “Open containing folder in Explorer” command to the barebones
Num+
, and it worked to run Explorer without also putting a+
in the document.So it’s exhibiting different behavior for Scintilla commands vs builting commands. This is then a bug, IMO.
@Bob-Smith-0 , for #1, I recommend you read our FAQ: Feature Request or Bug Report and put in an official Bug Report, where you explain that mapping
Num+
orNum-
to a Notepad++ command (like File > Open Containing Folder > Explorer) will map the action and correctly not type the+
or-
, but mappingNum+
to a Scintilla command (like SCI_LINESCROLLUP/DOWN) will cause it to do the Scintilla action and incorrectly also type the+
or-
.It seems that situations like the Num+ example should be trapped-out if a modifier isn’t added to the combination. Or, the “Num-x” commands should be an exception to the no-modifiers rule naturally, because there is always a way to get the character they represent, without the numeric keypad being involved.
Apparently, while my internal recommendation has always been “typeable”, the actual rule seems to not allow lonely alphanumeric, but the special keys and punctuation keys are mappable, even without modifier. So yes,
Num-x
commands are exceptions to the no-modifiers rule, but as Scintilla hotkeys they do “too much” -
@PeterJones said in Two Questions About Shortcut Mapper:
So it’s exhibiting different behavior for Scintilla commands vs builting commands. This is then a bug, IMO.
I traced this much. For Scintilla commands, Notepad++ calls SCI_ASSIGNCMDKEY to set the association and lets Scintilla handle it from there.
However, Scintilla doesn’t contain the message loop — Notepad++ does. And since keys assigned to Scintilla commands aren’t Notepad++ commands, they go through the normal call to TranslateMessage. Part of what TranslateMessage does is to add a WM_CHAR message following a WM_KEYDOWN for a printable character. TranslateMessage consults the keyboard layout and state to determine what character to send; for the plus key on the numeric keypad with no modifier keys down it creates a WM_CHAR message containing a “+” character.
The WM_CHAR message goes to Scintilla, which handles it here. Since “+” is not a control character, the code in the if block executes, and the character is added to the document.
Addressing this in Notepad++ would require either bypassing TranslateMessage without using either of the standard alternatives (IsDialogMessage or TranslateAccelerator) instead, or intercepting the DispatchMessage call for the WM_CHAR message. I don’t know what pitfalls those things might create, but either would be an “unusual” thing to do. It could get messy.
I don’t know if Scintilla could address it, because I don’t know the reasoning behind all the logic there. (It looks like it might be designed to skip ASCII control characters, but not printable or non-ASCII characters, when a command action was just triggered. I don’t know the reason for that choice, if that is what they intended.)
-
Github issue was created: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/14936
-
I tried the suggestions from @PeterJones (Thank You Very Much) to insert lines into my shortcuts.xml file to enable typing APL characters, which worked perfectly for all 94 macros.
There are 11 keys for which I had to scramble to find the corresponding virtual keycode. For others who may follow this path here they are
KeyCap KeyCode KeyName Semicolon/Colon 186 VK_OEM_1 Equal/Plus 187 VK_OEM_PLUS Comma/Leftcaret 188 VK_OEM_COMMA Hyphen/Underbar 189 VK_OEM_MINUS Period/Rightcaret 190 VK_OEM_PERIOD Slash/Query 191 VK_OEM_2 Backtick/Tilde 192 VK_OEM_3 Leftbracket/Leftbrace 219 VK_OEM_4 Backslash/Stile 220 VK_OEM_5 Rightbracket/Rightbrace 221 VK_OEM_6 Singlequote/Doublequote 222 VK_OEM_7
The above correspondences between KeyCaps and KeyNames were copied from a wensite I can’t mention here. There may be other sources, but this one worked for me.
Also, I tried replying to the previous message to thank the folks who helped me, but was told I needed a higher reputation. I tried upvoting to improve my rep, but that, too, needed a higher rep.
Instead, I’d like to thank you all for all of your help.
-
There are 11 keys for which I had to scramble to find the corresponding virtual keycode.
Those keystrokes are mentioned in the FAQ: List of Notepad++ key combinations, available for shortcuts – for example, VK_OEM_1 is in the “third part” in that FAQ. (Search that page for
third part
orVK_OEM_1
to find it)----
and Forum related stuff:
copied from a wensite I can’t mention here
No one had upvoted you yet, so you could not post links to external sites. (Otherwise, the forum just becomes an open invitation to spam bots; the amount of spam we have to deal with has dropped significantly since the link-reputation rule was put in.)
I tried replying to the previous message to thank the folks who helped me, but was told I needed a higher reputation.
You needed a higher reputation to post an external link; if it weren’t for that link, you would have been able to reply. I have used moderator powers to merge this back into the original discussion.
I tried upvoting to improve my rep
You cannot improve your own reputation yourself (otherwise, spammers would just upvote themselves or each other to get around this limitation).
I normally try to upvote well-asked questions, but forgot in your case. I have upvoted your posts, so things should be easier for you going forward.