Alt+X is an undocumented/unreported keyboard shotcut for main menu file - close
-
Hello, @mm-john, @peterjones, @neil-schipper and All,
Peter, I think that is a regular N++ shortcut ! Indeed, see the picture below :
If you click on the red cross, at the very end, on the right, representing an uppercase
X
letter, it just closes the current file !Best Regards,
guy038
-
@guy038 said in Alt+X is an undocumented/unreported keyboard shotcut for main menu file - close:
Hello, @mm-john, @peterjones, @neil-schipper and All,
Peter, I think that is a regular N++ shortcut ! Indeed, see the picture below :
If you click on the red cross, at the very end, on the right, representing an uppercase
X
letter, it just closes the current file !Guy, I think you misunderstood me. I have no doubt that the “close the active file” is a valid control that can be activated by keystroke. It’s also on the tabbar the red x next to the title of the tab; and in the tabbar right click menu. And finally, and most obviously, it’s available as File > Close. But the shortcut for File > Close defaults to
Ctrl+W
as can be seen in that menu and the shortcut mapper.The reason I called the
Alt+X
mapping a “backdoor” and rather than the standard shortcut-definition process is because theAlt+X
doesn’t show up anywhere in shortcut mapper, and when you try to program something else toAlt+X
, it doesn’t tell you there is a conflict, even though that shortcut is assigned somewhere else (magically, from the perspective of Shortcut Mapper). -
ALT+X works because this X in the upper right corner is defined as a menu item.
-
@ekopalypse said in Alt+X is an undocumented/unreported keyboard shotcut for main menu file - close:
ALT+X works because this X in the upper right corner is defined as a menu item.
… ah, and with all menu items, it can be accessed with
Alt+
the first letter (or other defined hotkey) from the menu item’s name. Hence, since the name isx
, thenAlt+X
will activate it. Just likeAlt+F
will activate the File menu. Got it.So @MM-John ,
Alt+X
working for that is a consequence of Windows standard behavior for menu bar access.However, as I’ve shown, you can override that by assigning Alt+X to something else. And I found the no-op code for macros (which I use for adding comments to macros): to do so with Alt+X, do the following:
- Close all Notepad++ instances
- Open one Notepad++ instance
- File > Open:
%AppData%\Notepad++\shortcuts.xml
- Scroll to the bottom of the
<Macros>
section - Add
<Macro name="AltXMacro" Ctrl="no" Alt="yes" Shift="no" Key="88"> <Action type="0" message="2172" wParam="0" lParam="0" sParam="COMMENT: 2172 is a no op command per scintilla.iface" /> </Macro>
- Save
- Exit Notepad++
- Open a new copy.
From now on,
AltXMacro
should be visible in the Macros menu, andAlt+X
should run that macro (doing nothing) instead of triggering the tab-closure. -
@ekopalypse said in Alt+X is an undocumented/unreported keyboard shotcut for main menu file - close:
ALT+X works because this X in the upper right corner is defined as a menu item.
Interesting that it isn’t defined as “&X”.
In general, I don’t like it.
It surprises the user. -
It would make it more obvious, yes.
-
@alan-kilborn said in Alt+X is an undocumented/unreported keyboard shotcut for main menu file - close:
Interesting that it isn’t defined as “&X”.
Windows defaults to the first letter of a menu item’s name if it is not otherwise defined, so it is not technically necessary. And I bet that Don didn’t want to underline it by default because then it would look funny — “why is the ✗ always underlined?” would become a new FAQ. And at this point, I bet there are a lot of users who have muscle-memoried
Alt+X
for closing the current tab, who would all show up out of the woodwork if Don were to disable that accelerator by default.
The following is being added to the manual in the shortcut mapper section:
Please Note: Notepad++ still honors standard Windows behavior with keystrokes for menu accelerators: typing
Alt
with the first letter (or underlined letter) for a main menu entry will open that menu. (Because theX
on the right of the menu bar, which closes the active tab, was created as a menu action on the main menu bar with the name “X”, it’s accelerator is thereforeAlt+X
.) If you want to defineAlt+
Letter for some other action, you may do so using the Shortcut Mapper, and that accelartor will no longer work for the menu, but will instead access the action you mapped it to. -
@peterjones said in Alt+X is an undocumented/unreported keyboard shotcut for main menu file - close:
why is the ✗ always underlined?
I think if it were underlined, it would be more obvious to users that Alt+x does this function. But…, no I’m not advocating any kind of change…
Notepad++ still honors
Why would you say “still” here?
-
@alan-kilborn said in Alt+X is an undocumented/unreported keyboard shotcut for main menu file - close:
Why would you say “still” here?
Because it was originally going to be in a “however, Notepad++ still honors…” phrasing. That was reworked, but the “still” remained. I will delete it before committing/merging.
-
@peterjones said in Alt+X is an undocumented/unreported keyboard shotcut for main menu file - close:
If you want to define Alt+Letter for some other action, you may do so using the Shortcut Mapper, and that accelartor will no longer work for the menu, but will instead access the action you mapped it to.
Further, if you later unmap that combination (by choosing None in the Shortcut mapper’s Modify dialog), the combination will revert to its former behavior of invoking the menu item it’s associated with as per the Windows standard.
(I confirmed this by temporarily remapping Alt-F & Alt-E to a macro, then unmapping them.)
(Also, typo “accelartor”)
-
@peterjones Wow that’s 13 more responses than I expected. Thanks for this active community and this awesome, community-supported tool.
Speculating, the &X would make it a npp shortcut and just “X” makes it a windows shortcut.
&X would have it underlined all the time?
And, I’m guessing, &X would also make it appear in the Shortcut Mapper? But, then deleting it from the Shortcut Mapper would just have it revert to windows so it wouldn’t be deleted from the user’s perspective? (that would be confusing)
I am guessing there’s no way to have windows (os-level) shortcuts appear in the Shortcut Mapper. So it will always be “incomplete” from a user point of view.
Perhaps a note at the bottom of the Shortcut Mapper that says “additional shortcuts from the (windows) OS are active even tho they are not represented here. A shortcut here will override the OS.” or something to that effect. Or even a tab for “windows shortcuts” to make it really obvious, with a panel that just is a message that explains that.
I did a quick search for how to report the current windows OS shortcuts and didn’t find anything.
I implemented your nop macro and it worked. Thanks!
I have portable, so the path to the
shortcuts.xml
is wherever thenotepad++.exe
is stored, ege:\npp.8.3.3.portable.x64\shortcuts.xml
Thanks again everyone!
-
@mm-john said in Alt+X is an undocumented/unreported keyboard shotcut for main menu file - close:
Speculating, the &X would make it a npp shortcut and just “X” makes it a windows shortcut.
Nope. When the developer prefixes a letter in the menu entry with the &, the developer is saying “Windows should use this letter as the accelerator key (if it can)”. It’s still Windows that is defining the behavior that
Alt+
Letter will open/activate that menu entry.&X would have it underlined all the time?
In any situation in which case the F of File, E of Edit, … t of Settings, o of Tool, … are underlined, the X of X would be, too. If they had defined it as
&X
And, I’m guessing, &X would also make it appear in the Shortcut Mapper?
Nope. Again, it’s not a “shortcut” from Notepad++'s perspective. It’s the Windows OS accelerator key for the menu entry. Notice for Windows that it doesn’t matter whether you type
Alt+F
to open the File menu orAlt
then let go and pause, then hitF
: it still opens the File menu in that sequence; andAlt
, Pause,X
will still close the active – that’s because it’s Windows OS handling the accelerator; it just tells Notepad++ “do whatever you’d do if someone clicked the File (or X) menu entry”. The Notepad++ Shortcut Mapper cannot define a keyboard shortcut that works that way; all Notepad++ keyboard shortcuts all must be simultaneously pressed, even if they have Alt in the shortcut.I am guessing there’s no way to have windows (os-level) shortcuts appear in the Shortcut Mapper.
You’re right, because it’s not a shortcut; it is a menu accelerator, implemented by the OS, not by the application.
Perhaps a note at the bottom of the Shortcut Mapper that says “additional shortcuts from the (windows) OS are active even tho they are not represented here. A shortcut here will override the OS.”
Please, no. Way too much clutter. The windows accelerators are not shortcuts; they are accelerators, and they work that way in every single windows win32 api-based application that I have used since Windows 3.11, from what I remember. At this point in the windows history, if a user doesn’t know that
Alt+
letter activates a menu with that accelerator letter, no amount of clutter in a user interface will help with that. The next version of the user manual will attempt to clarify this, but it’s really a Windows default behavior that has worked that way for decades.Because of this discussion, I have added the paragraph listed above to the user manual repository, so on the next release of the manual, it will be easily accessible in the same place that the shortcut mapper itself is documented.
I have portable, so the path to the shortcuts.xml is wherever the notepad++.exe is stored
That’s well documented in the User Manual. I got tired years ago of typing in every response in this forum “
shortcuts.xml
in%AppData%\Notepad++
or wherever you happen to have placed your portable version, or in your cloud directory, or in the-settingsDir
location”. If you are going to use something other than the standard installation, the onus is on you to understand how to translate the generic instructions into your specific configuration. If you had included the ?-menu’s Debug Info in your post, which would have told me that you had a non-standard installation, I would have customized my reply to your exact portable location. But barring that information being already transmitted to me, I will assume you have a standard installation. (And this despite the fact that for my entire workday every weekday, I am working out of a portable, and thus it’s more natural for me.)