SHIFT+left-click needs to select top-down not bottom-up
-
Notepad++ uses the “Scintilla” library to do the basic, low-level editing. Other editors that use the Scintilla component (like their SciTE testbed editor) also behave like Notepad++:
Ctrl A
followed by ashift-click
in the middle of the selection will select from the end to theshift-click
, rather than from the start.My guess is that there’s nothing the Notepad++ developers could do, because that behavior is inherited from Scintilla. Thus, I believe it would have to be added as an option to Scintilla, and then Notepad++ would have to create an option to either use that new Scintilla option or not.
I personally don’t see how
click
followed byCtrl+Shift+HOME
is any more heinous thanCtrl+A
followed byshift-click
. Each involves one click and three keys – they are just grouped differently: for the one you complain about, the click is alone and the three keys (CTRL
andSHIFT
andHOME
) are simultaneous; for the one you want it to be, you do two simultaneous keys, followed by key+click combination.But if you wanted, you could add a shortcut to SCI_DOCUMENTSTARTEXTEND to something with even fewer keys (for example, maybe pick
F10
, which is a single key) – and since Notepad++ allows multiple shortcuts for the same Scintilla commands, you don’t even have to get rid of theCtrl+Shift+HOME
in case you are used to using that sequence in other circumstances. With having a second SCI_DOCUMENTSTARTEXTEND keystroke ofF10
, it would lower your keypresses fromCtrl+A
thenShift+Click
to justClick
thenF10
, which is a net reduction in keypresses, without any change to the Notepad++ (or Scintilla) source code. -
@asapRepsnp said in SHIFT+left-click needs to select top-down not bottom-up:
Other text editors like Notepad, Textpad, and even word processors like MS Word DO select text from the top down to the cursor position, when using SHIFT+left-click.
Notepad++, Microsoft Notepad, plus Microsoft Word all operate exactly the same when I tried
Shift+left click
. All three editors set up a selection that went from the position of the caret or text cursor to the spot where I had positioned the mouse at the time I did theShift+left click
. All three editors also re-positioned the caret or text cursor to the spot I had clicked. Firefox in this mini-text editor for forum messages behaves in a similar the same way (FireFox does not reposition the caret). I don’t have Textpad and so can’t comment on that.However, both the Microsoft Notepad and Word that I use are older versions that have “classic behavior.” I’m wondering if newer versions of Microsoft Notepad and Word now behave like Firefox where
Shift+left click
selects from the caret to the mouse cursor but do not move the caret. If so, they would would select from the top of the file to the click point as long as you leave the caret on line 1, column 1.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.
-
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.