Community
    • Login

    Alt+X is an undocumented/unreported keyboard shotcut for main menu file - close

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    15 Posts 6 Posters 889 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • MM-JohnM
      MM-John
      last edited by MM-John

      I noticed this issue because I have started to hit Alt+X by accident because I installed the ‘XML Tools’ plugin which can be accessed via Alt+P, X and I’ve been hitting Alt+X as a typo lately.

      I looked in Settings -> Shortcut Mapper and I could find Ctrl+W, but no Alt+X

      I would love to be able to turn Alt+X off because of my particular situation. Doing that in the Shortcut Mapper seems a likely place.

      Here’s some screen shots:

      Ctrl+W (Main Menu - File - Close):

      2022_04_11_124326_notepad++_Shortcut_mapper.png

      and then,

      Alt+X (not found in any tab):

      2022_04_11_124400_notepad++_Shortcut_mapper.png

      This is not a very big deal, but I though it should be documented.

      This is npp 8.3.3 64bit portable.

      Neil SchipperN PeterJonesP 2 Replies Last reply Reply Quote 0
      • Neil SchipperN
        Neil Schipper @MM-John
        last edited by Neil Schipper

        @mm-john

        Good find.

        If you find your flying fingers persist in hitting that combo, make sure to get friendly with Ctrl+Shift+T!

        1 Reply Last reply Reply Quote 0
        • PeterJonesP
          PeterJones @MM-John
          last edited by

          @mm-john ,

          If you try to assign Alt+X to some other action, it does not show up as a conflict. And if you actually assign it, Alt+X will run the other action, rather than running the close-current-tab action.

          So, as a workaround, pick a dummy action or safe action, and assign it to Alt+X instead. I tried the experiment of Run > Run…, type echo in the box, and save to the name AltX with the Alt+X keystroke assigned. You can then cancel out of the Run… dialog, and see that AltX with keystroke Alt+X is now in the Run menu. Now typing Alt+X will just briefly pop up a cmd.exe window, instead of closing your active editor tab. You might be able to find an even better “do nothing” command than that (maybe manually craft a macro; there is a no-op style macro command, IIRC, so if you created such a macro with Alt+X as shortcut, you might get even better results – if I have time after lunch, I might come up with something for you).

          I am not a developer on Notepad++, but my guess is that the Alt+X shortcut comes from some “backdoor” rather than the standard shortcut-definition process, which is why it doesn’t show up in the shortcut mapper). Alternately, maybe it’s because there are two shortcuts assigned (Alt+X and Ctrl+W), whereas only the Scintilla tab of shortcut mapper can handle multiple shortcuts for the same command.

          BTW: we in the forum cannot make code changes. If this workaround is not enough for you, see our FAQ for an entry on how to submit an official feature request in the issue tracker. Without such an issue, the right people will not have been notified.

          1 Reply Last reply Reply Quote 1
          • guy038G
            guy038
            last edited by guy038

            Hello, @mm-john, @peterjones, @neil-schipper and All,

            Peter, I think that is a regular N++ shortcut ! Indeed, see the picture below :

            e7eef8ec-0b3b-4724-834e-bdab51eee53b-ALT+X.png

            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

            PeterJonesP 1 Reply Last reply Reply Quote 1
            • PeterJonesP
              PeterJones @guy038
              last edited by

              @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 the Alt+X doesn’t show up anywhere in shortcut mapper, and when you try to program something else to Alt+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).

              EkopalypseE 1 Reply Last reply Reply Quote 0
              • EkopalypseE
                Ekopalypse @PeterJones
                last edited by

                ALT+X works because this X in the upper right corner is defined as a menu item.

                PeterJonesP Alan KilbornA 2 Replies Last reply Reply Quote 2
                • PeterJonesP
                  PeterJones @Ekopalypse
                  last edited by

                  @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 is x, then Alt+X will activate it. Just like Alt+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:

                  1. Close all Notepad++ instances
                  2. Open one Notepad++ instance
                  3. File > Open: %AppData%\Notepad++\shortcuts.xml
                  4. Scroll to the bottom of the <Macros> section
                  5. 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>
                  
                  1. Save
                  2. Exit Notepad++
                  3. Open a new copy.

                  From now on, AltXMacro should be visible in the Macros menu, and Alt+X should run that macro (doing nothing) instead of triggering the tab-closure.

                  1 Reply Last reply Reply Quote 3
                  • Alan KilbornA
                    Alan Kilborn @Ekopalypse
                    last edited by

                    @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.

                    EkopalypseE PeterJonesP 2 Replies Last reply Reply Quote 1
                    • EkopalypseE
                      Ekopalypse @Alan Kilborn
                      last edited by

                      @alan-kilborn

                      It would make it more obvious, yes.

                      1 Reply Last reply Reply Quote 1
                      • PeterJonesP
                        PeterJones @Alan Kilborn
                        last edited by

                        @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 the X 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 therefore Alt+X.) 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.

                        Alan KilbornA Neil SchipperN MM-JohnM 3 Replies Last reply Reply Quote 2
                        • Alan KilbornA
                          Alan Kilborn @PeterJones
                          last edited by Alan Kilborn

                          @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?

                          PeterJonesP 1 Reply Last reply Reply Quote 0
                          • PeterJonesP
                            PeterJones @Alan Kilborn
                            last edited by

                            @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.

                            1 Reply Last reply Reply Quote 1
                            • Neil SchipperN
                              Neil Schipper @PeterJones
                              last edited by Neil Schipper

                              @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”)

                              1 Reply Last reply Reply Quote 0
                              • MM-JohnM
                                MM-John @PeterJones
                                last edited by

                                @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 the notepad++.exe is stored, eg

                                e:\npp.8.3.3.portable.x64\shortcuts.xml

                                Thanks again everyone!

                                PeterJonesP 1 Reply Last reply Reply Quote 0
                                • PeterJonesP
                                  PeterJones @MM-John
                                  last edited by PeterJones

                                  @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

                                  e9ad83a2-750d-4635-9f1d-37e479d5539b-image.png

                                  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 or Alt then let go and pause, then hit F: it still opens the File menu in that sequence; and Alt, 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.)

                                  1 Reply Last reply Reply Quote 2
                                  • First post
                                    Last post
                                  The Community of users of the Notepad++ text editor.
                                  Powered by NodeBB | Contributors