Selecting Text With the Use of the Ctrl + Shift + Up/ Down Combination
-
@Alan-Kilborn Paul’s point is that (old) Notepad.exe behaves differently from what Влад described, and speculates that the difference may be related to the language in effect.
This is actually kind of interesting (assuming Влад correctly described their observation) since, who would expect a nifty navigation (actually, text selection) feature in good old (old, old) Notepad to be available with some languages in effect but not the super-ubiquitous Western?
-
@Neil-Schipper said in Selecting Text With the Use of the Ctrl + Shift + Up/ Down Combination:
Paul’s point is that (old) Notepad.exe behaves differently…
Ah, OK. I’m so used to people referring to N++ as “notepad” that I read what Paul wrote wrongly. I try to always write “notepad.exe” (like you did) when referring to Windows’ poor excuse for a text editor.
-
@Neil-Schipper You summarized my point nicely and exactly.
In addition I like to pose the question to Влад: how do you recognize a paragraph boundary, either in notepad.exe or in Npp? Is it twice a CRLF, or one CRLF followed by, say, 3 spaces? It is of course not <p> or </p> as in HTML, or \par as in LaTeX.
-
@Влад-Котенко said in Selecting Text With the Use of the Ctrl + Shift + Up/ Down Combination:
The system’s default Notepad is also a text-editing program, and paragraphs can be selected in it with the use of the Ctrl + Shift + Up/Down combination
Interestingly, in my Windows 10
notepad.exe
at work,Ctrl+Shift+Up/Down
andCtrl+Up/Down
do nothing. But when I was playing around last night at home on Windows 11,notepad.exe
does respond to those combinations, similar to what you described… but not exactly. In that, what you called “start of paragraph” was always “start of current line”. If you havenotepad.exe
’s Word Wrap turned on, then one physical line (which wraps over multiple visible lines with Word Wrap on) would behave as you describe; but if I made a document ofone example one example one example one example one example one example | one example one example one example one example two example two example two example two example two example two example two example | two example three example will have a manual linebreak here and continues through the cursor | here
… and put the caret at the
|
intwo example
, the Ctrl+Shift+Up would take you to the beginning of line starting withtwo
. Similarly, if you put it in the|
ofcursor | here
, it would take you to the beginning ofand continues
, not to the beginning ofthree example
.So based on that, I think that “physical line that contains line wrap” is your definition of “paragraph”. So in Notepad++, running
Shift+Home+Home
(hold down shift, and hitHome
twice) will select to the beginning of the current line from wherever you are in the wrapped line that you call a “paragraph”. -
All,
BTW, I hadn’t yet mentioned: I started a conversation with the Scintilla maintainers. (For those who don’t know, Scintilla is the name of the library that Notepad++ uses for handling things in the editor tab, including the moving the caret around and the Paragraph Up/Down commands and similar; so they are the ones who decide whether any behavior of the Paragraph Up/Down is a “bug” or not.)
Scintilla’s definition of “Paragraph Up” is “move the caret up one physical line, then skip any blank lines, then keep going up while the current line is still non-empty”.
This means, in my original picture
… if you are on line 6, it will move back to line 5 and then stop, because line 4 is empty so it doesn’t move up to 4. But if you are anywhere on 3 (whether in the first visible line because of wrap or second visible line of wrap or whether wrap is off), it will go up one line first (to 2) then skip the blank line 2, and keep going up until it’s the top line of a group of non-empty lines (so goes up to the beginning of 1).The implication of the way the Scintilla library maintainer phrased his replies is that “Scintilla has been doing it this same way for years, and I’m not going to change it just because someone started complaining about it now.” So, unfortunately, the Scintilla library doesn’t look like it’s going to update that behavior. And since Notepad++ is not going to abandon Scintilla and “roll its own” for all the features that library implements, there is little-to-no chance that the paragraph-up behavior will change in Notepad++. Sorry.
But like I said earlier, if all of your “paragraphs” are really one long line with word-wrap turned on, then you can use the select-to-beginning-of-line sequence instead of select-paragraph-up, and that will work as expected wherever you are in your paragraph.
If your paragraphs are “mixed” (if you have multiple physical lines in one paragraph, but also have long lines wrapped), you can use the sequence of “select to beginning of line” first, then if it hasn’t selected to the top of what you consider the paragraph, use select-paragraph-up to get to the top of the multi-line paragraph. (So, from line 6’s
|
, the first would take you to the beginning of line 6, and the second would get you to the beginning of line 5.) -
So we can fix the “bad” Scintilla behavior with a little scripting. I think the following works to fix the “paragraph up extend” functionality. If anybody wants to try it, some instructions for setting up and running a script are HERE.
# -*- coding: utf-8 -*- from __future__ import print_function # references: # https://community.notepad-plus-plus.org/topic/23737 # https://sourceforge.net/p/scintilla/bugs/2363/ from Npp import * import re #------------------------------------------------------------------------------- class T23737(object): def __init__(self): if editor.getSelections() > 1: return # conditions not correct for running this script sel_mode = editor.getSelectionMode() rect_sel_mode = True if (sel_mode == SELECTIONMODE.RECTANGLE or sel_mode == SELECTIONMODE.THIN) else False if rect_sel_mode: return # conditions not correct for running this script #self.para_up() self.para_up_extend() def para_up(self): self.internal_para_up(False) def para_up_extend(self): self.internal_para_up(True) def is_white_line(self, line_num): return False if re.search(r'[^\t ]', editor.getLine(line_num).rstrip('\n\r')) else True def internal_para_up(self, extend_sel): curr_anchor, curr_pos = editor.getAnchor(), editor.getCurrentPos() line_num = editor.lineFromPosition(curr_pos) line_start_pos = editor.positionFromLine(line_num) if curr_pos == line_start_pos or self.is_white_line(line_num): line_num -= 1 while line_num >= 0 and self.is_white_line(line_num): line_num -= 1 # skip empty lines while line_num >= 0 and not self.is_white_line(line_num): line_num -= 1 # skip non-empty lines line_start_pos = editor.positionFromLine(line_num + 1) editor.setSel(curr_anchor if extend_sel else line_start_pos, line_start_pos) # arguments: anchor, caret #------------------------------------------------------------------------------- if __name__ == '__main__': T23737()
Edit: minor tweaks to script after original post!
-
A Alan Kilborn referenced this topic on
-
quotation: “The behavior of shift+ctrl+up seems to be locally defined (I presume that you are in country where cyrillic is the standard script). In my Western-European setting neither Notepad nor MS-Word jumps to the end of the paragraph. My Notepad doesn’t do anything when I hit shift+ctrl+up and MS-Word creates a stream block from the current caret position to the beginning of the paragraph.”
The US version of Windows 11 is installed on my computer, and the primary keyboard language and layout are US English. I think that the Ctrl + Shift + Up/ Down shortcut functions in the same way in other versions. I did not know that it may function differently on some computers.
quotation: “Have a good day:
Triple click with the left mouse button also has that function.
The idea of some keyboard shortcuts is to minimize the time it takes to get your hand to the mouse and then back to the keyboard.
If it is to effectively avoid the use of the mouse for that single function, I haven’t said anything!.. :)
I wish you success.”
Yes, a triple click is a convenient way to make a selection quickly when one’s hand is currently on the mouse.
But when the hands are on the keyboard, a shortcut is convenient.
quotation: “In addition I like to pose the question to Влад: how do you recognize a paragraph boundary, either in notepad.exe or in Npp? Is it twice a CRLF, or one CRLF followed by, say, 3 spaces? It is of course not <p> or </p> as in HTML, or \par as in LaTeX.”
I view a paragraph as a block of text which is preceded by a break at the beginning and followed by a break at the end. A paragraph occupies more than one line if the word wrap option is enabled. A break is made by pressing the Enter key.
quotation: “So based on that, I think that “physical line that contains line wrap” is your definition of “paragraph”.”
Yes, that is how I view paragraphs. The word wrap option is always enabled in my text-editing programs.
quotation: “Scintilla’s definition of “Paragraph Up” is “move the caret up one physical line, then skip any blank lines, then keep going up while the current line is still non-empty”.
…
The implication of the way the Scintilla library maintainer phrased his replies is that “Scintilla has been doing it this same way for years, and I’m not going to change it just because someone started complaining about it now.” So, unfortunately, the Scintilla library doesn’t look like it’s going to update that behavior. And since Notepad++ is not going to abandon Scintilla and “roll its own” for all the features that library implements, there is little-to-no chance that the paragraph-up behavior will change in Notepad++. Sorry.”
Thank you for the explanation. I will have to get accustomed to the different functioning of Notepad++.
quotation: “So we can fix the “bad” Scintilla behavior with a little scripting. I think the following works to fix the “paragraph up extend” functionality. If anybody wants to try it, some instructions for setting up and running a script are HERE.”
Thank you for writing the script. Since I have never added a piece of code, I will find out how to do this in order to use the script. -
@PeterJones said in Selecting Text With the Use of the Ctrl + Shift + Up/ Down Combination:
I started a conversation with the Scintilla maintainers.
Scintilla’s definition of “Paragraph Up” [was] “move the caret up one physical line, then skip any blank lines, then keep going up while the current line is still non-empty”.The good news is, they accepted it. Scintilla v5.3.2 uses the adjusted definition, so it won’t do the initial line-up under most circumstances: The new phrasing could be
Scintilla’s definition of “Paragraph Up” is “if the caret is at the start of the line then move the caret up one physical line, then no matter what skip any blank lines going up, then keep going up while the current line is still non-empty”.
-
@PeterJones said in Selecting Text With the Use of the Ctrl + Shift + Up/ Down Combination:
@PeterJones said in Selecting Text With the Use of the Ctrl + Shift + Up/ Down Combination:
I started a conversation with the Scintilla maintainers.
Scintilla’s definition of “Paragraph Up” [was] “move the caret up one physical line, then skip any blank lines, then keep going up while the current line is still non-empty”.The good news is, they accepted it. Scintilla v5.3.2 uses the adjusted definition, so it won’t do the initial line-up under most circumstances: The new phrasing could be
Scintilla’s definition of “Paragraph Up” is “if the caret is at the start of the line then move the caret up one physical line, then no matter what skip any blank lines going up, then keep going up while the current line is still non-empty”.
Thank you for the update. I guess that it may take some time before any improvements in the functionality of the program are made.
-
@PeterJones said in Selecting Text With the Use of the Ctrl + Shift + Up/ Down Combination:
The good news is, they accepted it. Scintilla v5.3.2 uses the adjusted definition
The “better” news – Notepad++ may be upgrading soon again …
Cheers.
-
@Michael-Vincent said in Selecting Text With the Use of the Ctrl + Shift + Up/ Down Combination:
The “better” news – Notepad++ may be upgrading soon again …
@PeterJones
@Влад-Котенко-0The “best” news - it will be in the next release. I downloaded the artifact and it seems to work as intended!
Cheers.