Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Ctrl+A, then Shift + Mouse Click - unwanted behaviour

    Help wanted · · · – – – · · ·
    3
    5
    1181
    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.
    • James Pike
      James Pike last edited by

      Hi all.

      I am trying to get to grips with Notepad++, and there is one keyboard/mouse shortcut that I find really useful in other packages that I can’t seem to replicate in Notepad++.

      In other text editors, Word, or even Chrome, if you select all using Ctrl+A, then hold down shift while you mouse click in the text/document this results in everything being selected from the start of the text/document to where the mouse click is, and the screen focus is at the point of click.

      If you use this same key/mouse combo in Notepad++ the selection is the inverse of what is given in other packages. I.e. the selection is from the point of click to the end of the document.

      The closest I have discovered is to first click in the text then shift+ctrl+home. However, this moves the screen focus to the start of the text/document.

      Any help would be appreciated!

      1 Reply Last reply Reply Quote 0
      • dail
        dail last edited by dail

        I ended up fixing this myself a while ago. The reason is that the selection’s anchor is at the bottom of the text, and the cursor is at the top…which as you have discovered is backwards from almost all other applications. Though this is more of a Scintilla bug rather than Notepad++, you can still work around it.

        Install LuaScript via the PluginManager, use the Plugin menu to edit the startup script for LuaScript, paste the following code, save, and then restart:

        npp.AddShortcut("Select All", "Ctrl+A", function()
        	editor:ClearSelections()
        	editor:SetSelection(editor.Length, 0)
        end)
        
        1 Reply Last reply Reply Quote 3
        • guy038
          guy038 last edited by guy038

          Hello @james-pike, @dail and All,

          An other method, which does not involve any plugin, would be to create a macro, which uses the SCI_SWAPMAINANCHORCARET Scintilla message. This message, simply, swaps the locations of the anchor and the caret, of the last normal selection

          So, once you identified the correct location of your active shortcuts.xml configuration file :

          • Stop any instance of N++

          • Add, in macros section of shortcuts.xml, the following macro :

                  <Macro name="Select All - Anchor at Pos 0" Ctrl="yes" Alt="no" Shift="no" Key="187">
                      <Action type="0" message="2013" wParam="0" lParam="0" sParam="" />
                      <Action type="0" message="2607" wParam="0" lParam="0" sParam="" />
                  </Macro>
          
          • Restart Notepad++

          From now on, once a Select All operation is performed ( Ctrl+ A ) :

          • To select from caret location to the very end of the file

            • Hold down the Shift button and click at any location
          • To select from caret location to the very beginning of the file :

            • Run the above Select All - Anchor at Pos 0 macro

            • Hold down the Shift button and click at any location

          Of course, you may attribute a shortcut to this new macro ( Settings > Shortcut Mapper... > Macros > Select All - Anchor at Pos 0 )

          Best Regards

          guy038

          P.S. :

          @dail, Two questions :

          • I don’t see the necessity to add the editor:ClearSelections() command as, regarding the Scintilla message SCI_SETSELECTION(int caret, int anchor), it is said “Set a single empty selection at 0 as the only selection.” ?

          • If you have used the editor:SetSel(0, editor.Length) command ( instead of editor:SetSelection(editor.Length, 0) ), I suppose that it would had been identical, but with a scrolling to the end of document, at caret location ?

          1 Reply Last reply Reply Quote 1
          • dail
            dail last edited by

            Two questions :

            I simply rewrote the logic that Scintilla implements and swapped the selection start/end. See

            https://github.com/mirror/scintilla/blob/fb378d0f547173ee0af340e5071785d7ad54c30b/src/Editor.cxx#L2215-L2219

            I’m not sure if editor:ClearSelections() is needed but kept it in there since that what Scintilla does.

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

              Hi @dail,

              I’m sorry ! In my previous post, I just forgot to thank you for your… future reply ! So, I do ;-))

              Cheers,

              guy038

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Copyright © 2014 NodeBB Forums | Contributors