SHIFT+left-click needs to select top-down not bottom-up
-
From my reading of the OP’s “problem”, Ctrl+a is involved as a first step. I don’t think what you are saying takes that into account.
Ctrl+a (to select-all) results in the somewhat counter-intuitive positioning of the caret at the beginning of the file rather than the end. If it positioned the caret at the end, the OP’s problem wouldn’t exist and we would be talking about this.
BTW, I saw it is counter-intuitive because most people, when making a lengthy selection, tend to do it from a smaller line number in the file to a larger line number, not the other way around. Doing it this way results in the caret on the line of the larger line number.
-
@PeterJones
re: I personally don’t see how click followed by Ctrl+Shift+HOME is any more heinous than Ctrl+A followed by shift-click. Each involves one click and three keysWhen I am doing this, I have my left hand for the keyboard, and the right hand is on a trackball away from the keyboard. I need to do certain tasks quickly, and in numerous documents, so time is of the essence.
With other text editors, selecting all text from the top down to the current cursor position is a quick:
1- Ctrl+A with the left hand followed immediately by
2- Shift (hold) with the left hand and
3- Left-click of the pointer using the right hand on the trackball. And it doesn’t matter where the cursor is BEFORE doing Ctrl-A. It selects to where the pointer (cursor) is at when the click is done.It’s done in a second or less.
And… (a benefit in my opinion…) the cursor is still at the position where the click was done, so I can SEE exactly where the selection ends.
In NPP, I have to:
1- Left-click the pointer to position the cursor where I want it in the document FIRST using my right hand on the trackball
2- Ctrl+Shift (hold) with the left hand
3- Move my right hand from the trackball and press Home. This is the “time consuming” extra effort that takes a few seconds or more (for me).But… ( I forgot to mention this before…) NPP warps the document to the top, it is no longer at the spot that I picked, unlike other editors. If I want to keep working at that spot after doing the selection, I’ve got to find it again, instead of it already being there. It could be thousands of lines down.
Assuming I can do everything correctly the first time, it takes me much longer (4-7 sec or more???) to complete the same task in NPP, mainly because I have to program my feeble brain to use BOTH hands on the keyboard instead of one. I have to remove my right hand from the trackball and then I have to look at the keyboard trying to find the Home key with my right hand, spending extra time. It doesn’t help when changing keyboards, either!
NPP just doesn’t “flow” as well as when doing the same operation in other text editors, especially when considering Ctrl+A is the same in all editors I have used.
I might try changing the default shortcut for SCI_DOCUMENTSTARTEXTEND from Ctrl+Shift+Home to something like Ctrl+Shift+A which would use just the left hand. But that doesn’t get rid of the annoyance of the warping of the cursor to the top of the document.
Settings > Shortcut Mapper > Scintilla commands tabThanks for the input. That pointed me in the right direction to maybe put a band-aid on my “issue”.
-
@mkupper said in SHIFT+left-click needs to select top-down not bottom-up:
What you are asking for seems to be non-standard behavior and I’m wondering this desire for change is based more on not understanding the difference between the caret or text cursor and the mouse cursor.
All I know is that with other text editors, I can have the cursor/caret (I’m sure I don’t understand the difference of them) anywhere in a document. I can scroll down/up and be “screens” away from the cursor position. Then when I do Ctrl+A and Shift+left-click of the pointer, ALL text is selected from the top to wherever the pointer was positioned at the time of the click.
When I do Ctrl+Shift+Home in NPP, Textpad, and Notepad (3 that I have tried), they do the same action. I had never TRIED using Ctrl+Shift+Home in Textpad or Notepad before, because I didn’t need to. The other method was (still IS) much better for me.
-
@Alan-Kilborn Thank you. Yes, I had missed the initial
Ctrl+A.
I experimented a bit more. All three editors (Notepad++, Microsoft Notepad, and Microsoft Word) have very similar behavior.It seems that for
Shift+left click
all three editors draw a selection from the caret to the mouse cursor. If any of the area spanned by this selection was already selected then it’s unselected. All three editors also reposition the caret to the spot that was clicked.However, if you first do a
Ctrl+A
then:- Notepad++ positions the caret at line 1, col 1. When the
Shift+left click
is done it follows the usual rules described above meaning the part above the spot clicked becomes unselected. - Microsoft Notepad and Word both position the caret at the bottom of the file. When the
Shift+left click
is done it follows the usual rules described above meaning the part below the spot clicked becomes unselected.
It seems that if we could either change Notepad++'s behavior for Ctrl+A or Scintilla’s behavior for SCI_SELECTALL (message # 2013) so the caret ends up at the bottom of the file instead of the top then everything would match what @asapRepsnp expected.
I did a search of the forums for “select all” “caret” and found Ctrl+A, then Shift + Mouse Click - unwanted behaviour from 2018 and seems to have two solutions. My brain is too fried at present to test these.
(later edit) I tried @guy038 's macro from the t2018 thread, which is for
Ctrl+=
for those that want to experiment. While it does the select-all the caret ended up at at line 1, col 1 and the resultingShift+left click
behaved the same as the usualCtrl+A
select meaning the text from the clicked spot down to the bottom is selected rather than the desired top of file to the clicked spot. - Notepad++ positions the caret at line 1, col 1. When the
-
This post is deleted! -
@Alan-Kilborn said in SHIFT+left-click needs to select top-down not bottom-up:
Ctrl+a (to select-all) results in the somewhat counter-intuitive positioning of the caret at the beginning of the file rather than the end. If it positioned the caret at the end, the OP’s problem wouldn’t exist and we would be talking about this.
I’m not very familiar with the scripting plugins, nor with macros, but would either be able easily to replace
Ctrl+A = SCI_SELECTALL
with
Ctrl+A = SCI_SETANCHOR(0), SCI_SETCURRENTPOS(SCI_GETLENGTH)Since, according to the documentation, neither SCI_SETANCHOR nor SCI_SETCURRENTPOS scrolls the caret into view, that should give the behavior the original poster expects.
As a general solution, it would make sense if it were possible to reassign Ctrl+Shift+[Home|End] so that they execute SCI_SETANCHOR(0|SCI_GETLENGTH), thereby selecting what is desired while leaving the cursor where it is — you probably want to do that more often than you want to lose your place and move to the beginning or the end while selecting. But I’m assuming the original poster is more concerned with keeping a familiar behavior intact so it doesn’t require relearning for Notepad++.
-
Perhaps SCI_SWAPMAINANCHORCARET would also be useful here.
-
@Alan-Kilborn said in SHIFT+left-click needs to select top-down not bottom-up:
Perhaps SCI_SWAPMAINANCHORCARET would also be useful here.
I tried creating a Notepad++ macro that would “select all” and then do the “swap” (thinking that it could be used as a Ctrl+a substitute for the OP), but the swap part seemed to have no effect when the macro runs. The caret remains at the top-of-document. :-(
Scripting seems like overkill, but this works (to leave the caret at end-of-document) as a Ctrl+a replacement:
editor.selectAll() editor.swapMainAnchorCaret()
As NppExec is “simpler” than Python scripting, this seems to work as a NppExec script:
sci_sendmsg SCI_SELECTALL sci_sendmsg SCI_SWAPMAINANCHORCARET
-
@asapRepsnp, the PythonScript posted by @Alan-Kilborn will work for you. It’s does the usual Notepad++ style Select-All that leaves the cursor at the top of the file but then calls a function that swaps the head and tail of the selection created by Select-All. This moves the cursor to the bottom of the file.
At that point,
Shift+left click
will behave the way as it does in other editors.While the PythonScript is just two lines long implementing it may be technically challenging. In summary:
- Install the PythonScript plugin.
- Create a new PythonScript file filled in with the two lines Alan provided. I named mine SelectAll.py
- Go to the PythonScript Configuration settings and add SelectAll.py to the list of Menu items.
- Exit Notepad++ and restart it. I’m not sure if this step is necessary these days but it’s to make the new menu item visible to the next step.
- In Notepad++'s
Settings / Shortcut mapper / Scintilla commands
double click on line 1 which is for SCI_SELECTALL and change the key assigned fromA
toNone
which is at the top of the drop-down. Click [Apply] and a message will appear about “This will remove shortcut from this command”. Click [Ok]. - Switch to the Plugin commands tab of the shortcut mapper. Your new SelectAll should be visible near the bottom of the long list. Double click that and assign
Ctrl
andA
to this. - Click [ok] and [Close] and now Ctrl-A will work “correctly.”
- If you do
Edit / Select All
from Notepad++'s drop down menus then you will still get the old “broken” version of select-all that positions the cursor at the top of the file.
-
@mkupper said in SHIFT+left-click needs to select top-down not bottom-up:
While the PythonScript is just two lines long implementing it may be technically challenging. In summary
Good summary for this specific case.
For the general case with a bit more hand-holding, see the FAQ entry.If you do Edit / Select All from Notepad++'s drop down menus then you will still get the old “broken” version of select-all
Note that it is only “broken” in terms of how the OP thinks about it. There is no bug with Select All, just because Notepad++ happens to do it differently from some other editors.