[v.7.8.6] Vertical Edge Settings no longer works with Split Lines (Ctrl-I)
-
@Matthew-Au said in [v.7.8.6] Vertical Edge Settings no longer works with Split Lines (Ctrl-I):
And shall I raise this as an issue in N++ Github?
I would say YES to this.
-
@Matthew-Au said in [v.7.8.6] Vertical Edge Settings no longer works with Split Lines (Ctrl-I):
And shall I raise this as an issue in N++ Github
Yes please. And reference / link this discussion please.
@Matthew-Au said in [v.7.8.6] Vertical Edge Settings no longer works with Split Lines (Ctrl-I):
Can this issue be workaround via GUI?
I didn’t notice this because I use NppExec to run a startup script (as soon as N++ launches) and among other things, it force sets Edge Line mode and column 80. I added it after this new release that changed the way vertical edge was done. I hadn’t noticed your issue since I was always forcing Edge Line mode.
Cheers.
-
@Ekopalypse Thanks, the “background mode” does the job (for now).
@Alan-Kilborn I’ve submitted a bug report here.
-
Hello, @matthew-au, @michael-Vincent, @ekopalypse and All,
I fully understand the problem ! In order to get the
Split Linesfeature to work, here is my work-around :-
Open the
Settings > Preferences... > Editing > Vertical Edge Settingsoption -
If the window contains
severalcolumn numbers, delete all these numbers -
Now, type in an
uniquecolumn number where you want the lines to be splitted -
Tick the
Background modeoption ( IMPORTANT ) -
If preferred, you can untick this option, immediately !
-
Now the
Ctrl + Ifeature should be fucntional, as soon as a selection have been made, whatever theBackgroundorLinemode is chosen ;-)) -
If you want, you may rewrite all your previous column numbers
-
But, beware that any subsequent
Ctrl + Ioperation will refer to the unique number noticed while ticking theBackground modeoption !!
Here is my debug info :
Notepad++ v7.8.6 (32-bit) Build time : Apr 18 2020 - 22:32:17 Path : D:\@@\786\notepad++.exe Admin mode : OFF Local Conf mode : ON OS Name : Microsoft Windows XP (32-bit) OS Build : 2600.0 Plugins : Explorer.dll mimeTools.dll NppConverter.dll NppExport.dllBest Regards
guy038
-
-
@guy038 said in [v.7.8.6] Vertical Edge Settings no longer works with Split Lines (Ctrl-I):
beware that any subsequent Ctrl + I operation will refer to the unique number noticed while ticking the Background mode option !!
Hidden feature!! :-)
-
@guy038 but works only as long as you don’t restart npp, correct?
-
Hi, @matthew-au, @michael-Vincent, @ekopalypse, @alan-kilborn and All,
@ekopalypse, Ah yes ! As soon as I restarted Notepad++, it simply showed the two edge lines that I had previously set (
30and60)However, remember that, by default, if
novertical setting orseveralvertical settings are set, then theCTRL + Ifeature splits lines, roughly, to the windows text width !Cheers,
guy038
-
Hello, @matthew-au, @michael-Vincent, @ekopalypse, @alan-kilborn and All,
The last N++
v7.8.6version now supports the newVertical Multi-Edge linesfeature. Unfortunately, as a consequence, this definitively breaks the nativeSplit Linesfeature (Ctrl + I)A work-around has been found but needs to choose
onecolumn number only and tick once on theBackground modeoption ! But this prevent you from easily using multiple vertical lines, which is a pity :-(So, I imagined a regex S/R, that exactly simulates the N++
Split Linesfeature ;-))Just one constraint : If your text contains some
tabulationchars, you must run, first, theEdit > BLank Operations > TAB to Spaceoption, in order to change anytabcharacter with the appropriate number of space chars. Indeed, the regex S/R assumes that each character displayed takes the place of exactly one character. !The generic regex S/R, for any splitting column C is :
SEARCH
(?-s)^(?=.{C})(.{1,C-3}\x20|.{C-1})\KREPLACE
\r\n( or\nif Unix files )So, let’s suppose that you want to split text, at column C =
80. In that case, the regex S/R must be changed as below :-
SEARCH
(?-s)^(?=.{80})(.{1,77}\x20|.{79})\K -
REPLACE
\r\n( or\nif Unix files ) -
Tick the
Wrap aroundoption -
Select the
Regular expressionsearch mode -
CLick on
Replace Allbutton, exclusively ( Do not use theReplacebutton ! )
After numerous tests, I verified that the split texts are strictly identical :
-
Whatever the
Split Linesoption (Ctrl + I) or the Regex S/R is used -
Whatever the
In selectionoption is set or not, in the Replace dialog -
Whatever the
LineorBackgroundmode is used, inSettings > Preferences... > Editing > Vertical Edge Settings -
Whatever the
View > Word wrapoption is set or not -
Whatever the
View > Show Symbol > Show All Charactersoption is set or not -
Whatever the current font used is a
MonoSpaceor aProportionalfont, in theStyle Configurator...
In case of a
proportionalfont, do not trust the visualvertical edgeline, but rely on the real column, indicated inSettings > Preferences... > Editing > Vertical Edge Settings! BTW, theLinemode is generally recommended for monospace fonts and theBackground modeshould be preferred for proportional fonts !
As a test, we’ll simply use the
License.txtfile and split its contents at column80:-
First of all, make sure that the single number
80is shown inSettings > Preferences... > Editing > Vertical Edge Settings -
Copy the
License.txtfile in two new tabs (new 1andnew 2) -
In the
new 1file :-
Ctrl + A -
Ctrl + I(Split Linesoption )
-
-
In the
new 2file :-
Open the Replace dialog (
Ctrl + H)-
SEARCH
(?-s)^(?=.{80})(.{1,77}\x20|.{79})\K -
REPLACE
\r\n( or\nif Unix files ) -
Tick the
Wrap aroundoption -
Select the
Regular expressionsearch mode -
Click on
Replace Allbutton, exclusively ( Do not use theReplacebutton ! )
-
-
-
Now, compare the two tabs with, for instance, the
Compareplugin or with an external compare tool => The two tabs should be strictly identical ;-))
Remark : Of course, this regex S/R supposed that the splitting vertical line was at position
80. So, adapt the generic regex, above, according to the real column needed !Best Regards,
guy038
-
-
Seems to be relevant to this current discussion: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/7814
-
-
Hi, @alan-kilborn and All,
You’re perfectly right about it : No need of a capturing group for that purpose ! So, the generic search regex can be changed as below :
SEARCH
(?-s)^(?=.{C})(?:.{1,C-3}\x20|.{C-1})\KAnd the corresponding search regex for C =
80is :SEARCH
(?-s)^(?=.{80})(?:.{1,77}\x20|.{79})\KIndeed, although the maximum of characters, caught in group
1, not exceeds, either, C-2 or C-1 chars, the fact of using a non-capturing group should speed up the replacement process, in case of huge files !Cheers,
guy038
-
Not sure this is worth a new thread … I used the following NppExec / Scintilla script to set the vertical edge column to the current column (super useful in my usage). It is now broken. Any recommendations for how to fix is appreciated. I did try what I thought was the obvious update and it didn’t work…
::NPXEdgeColumSetToCurrent
NPP_CONSOLE ?
SCI_SENDMSG SCI_SETEDGECOLUMN $(CURRENT_COLUMN) -
@Patrick-Sheppard said in [v.7.8.6] Vertical Edge Settings no longer works with Split Lines (Ctrl-I):
It is now broken
What version of Notepad++ - please post your debug info (menu ? => Debug Info…). I’ll assume you’re using the new 7.8.6 version as that is an easy fix. As of N++ 7.8.6, the vertical edge mode changed to multiedge by default so you can add multiple edges. You can try:
SCI_SENDMSG SCI_GETEDGEMODE ================ READY ================ ECHO $(MSG_RESULT) 1to verify. I’m assuming you’ll get back “3” as in EDGE_MULTILINE. You can modify your script to be:
::NPXEdgeColumSetToCurrent NPP_CONSOLE ? SCI_SENDMSG SCI_SETEDGEMODE EDGE_LINE SCI_SENDMSG SCI_SETEDGECOLUMN $(CURRENT_COLUMN)Cheers.
-
Thanks, Michael.
I had downgraded to 7.8.5 because of this issue and was reluctant to jump back up, but I just did and your modification works a charm.
Appreciated.
-
Hello, @matthew-au, @i-neuw, @michael-Vincent, @ekopalypse, @alan-kilborn, @peterjones, @terry-r and All,
I revisited my previous posts of that discussion about the new
Vertical Multi-Edge linesfeature !First, when I said :
A work-around has been found but needs to choose
onecolumn number only and tick once on theBackground modeoption !I want to insist that the fact of ticking on the
Background modeoption, then unticking it, is needed to update the sole edge boundary value, displayed ! Even with the last7.9.0N++ version, this step is necessary !
Now, I did some additional tests, on, both, the final version of my regex and the native
Split LinesN++ feature (Ctrl + I), using thelicense.txtfile !-
Using my regex S/R method, to split the lines, we get the same result :
-
Whatever the
LineorBackgroundmode is used, inSettings > Preferences... > Editing > Vertical Edge Settings -
Whatever the
View > Word wrapoption is set or not -
Whatever the
View > Show Symbol > Show All Charactersoption is set or not -
Whatever the current font used is a
MonoSpacedor aProportionalfont, in theStyle Configurator...
-
provided that you previously ran the
Edit > BLank Operations > TAB to Spaceoption if your file contains someTABcharacters !
-
Using the native
Edit > Line Operations > Split Linesfeature, we get the same result-
Whatever the
LineorBackgroundmode is used, inSettings > Preferences... > Editing > Vertical Edge Settings -
Whatever the
View > Word wrapoption is set or not
-
But, unlike what I said in my first post, the results of the
Ctrl + Ifeature are totally different depending on whether :-
The
View > Show Symbol > Show All Charactersoption is set or not -
The current font used is a
Monospacedor aProportionalfont, in theStyle Configurator...
So, regarding my previous argumentation, my regex method and the native
Split LinesN++ feature give the same results ONLY IF :-
A monospaced font is currently used
-
The EOL symbol (
CRLF) is not displayed -
The column number is superior to a minimum of about
15for normal text. When I say “normal”, I refer, for instance, to thelicense.txttext, from line28GNU GENERAL PUBLIC LICENSE Version 2, June 1991 till the end of file !
Note also that, with these hypotheses, the splitting operation of a selection of lines with, both, the regex S/R and the native
Split Linesfeature gives the same text contents !
IMPORTANT : My regex S/R is built in order to exactly replace the native
Split LinesN++ feature, with the hypotheses above. But, of course, you may decide to not follow this rule and use, instead, a more simple search regex as, for instance :SEARCH
(?-s)^.{75,}?\K\x20+REPLACE
\r\nwhich would split lines, roughly, after
80charactersBest Regards,
guy038
-
-
Posting this in case it’s useful to anyone else. I worked around this issue using this plugin: dail8859/LuaScript: Notepad++ plugin for Lua scripting capabilities. Specifically, I added this code to my Lua startup script.
-- Lua function for Scintilla colors local function RGB(red, green, blue) return red | green << 8 | blue << 16 end -- Teal color value same as default used in Notepad++ local COLOR_TEAL = RGB(128, 255, 255) -- Set line mode to EDGE_Line at 80 characters with teal color npp.SendEditor(SCI_SETEDGEMODE, EDGE_LINE) npp.SendEditor(SCI_SETEDGECOLUMN, 80) npp.SendEditor(SCI_SETEDGECOLOUR, COLOR_TEAL)So, every time Notepad++ starts it resets the column marker. This has the same affect as if one were to toggle the “Background mode” setting.
-
Thanks for your contribution.
It is a Lua variation on @Michael-Vincent 's original NppExec solution.
There hasn’t been a Pythonscript implementation, so I’ll add that now:editor.setEdgeMode(1) editor.setEdgeColumn(80) -
@Alan-Kilborn said in [v.7.8.6] Vertical Edge Settings no longer works with Split Lines (Ctrl-I):
Pythonscript implementation
And of course “PerlScript”:
editor->setEdgeMode( $SC_EDGEMODE{EDGE_LINE} ); editor->setEdgeColumn(80);Cheers.
-
-
@Matthew-Au @rd4gh @Alan-Kilborn @Michael-Vincent and all
Since this is the older thread I will drop my two cents here.
Notepad++ v7.8.6 introduced support for drawing multiple vertical lines (also called “edges”) inside of an editor window. But this new feature is not simply an extension of the old well-known single-edge-line feature, instead it is a completely new edge mode that replaced the old one. Unfortunately this broke the ability to word-wrap a document’s content at such an edge line (using the standard keyboard shortcut
Ctrl+I).In the following I provide some scripts for the NppExec plugin to get back the old single-edge-line feature and being able to control it. Additionally I provide a fixed implementation of the related “word-wrap at single-edge-line” feature. That’s because I became aware that Notepad++'s internal implementation of this feature has two bugs:
-
If the font size of the line numbers margin is set to a different value than the font size for documents, the “word-wrap at single-edge-line” code calculates a wrong wrapping position. This position has to be provided in pixels. To calculate this pixel value, a Scintilla function has to be called that calculates the width in pixels of a provided string from a provided text style. It seems like Notepad++'s internal code erroneously takes the text style of the line numbers margin font when calling this Scintilla function.
-
To generate the template string for the pixel calculation mentioned above, it is necessary to query the set column number of the single-edge-line. Since column numbers in Scintilla are 0-based, the retrieved result has to be incremented by 1 to get the required length of the template string. It seems Notepad++'s internal code doesn’t do that because when word-wrapping a line that has a word boundary exactly at the single-edge-line it wraps this line at the beginning of that word instead at its end.
Here are the scripts. Most of them could be assigned to a keyboard shortcut using Shortcut Mapper.
Initialize Single-Edge-Line Mode
::SetSingleEdgeLine npp_console keep sci_sendmsg SCI_SETEDGECOLUMN 80 sci_sendmsg SCI_SETEDGEMODE EDGE_LINEThis script is intended to be used as a NppExec startup-script. It sets the single-edge-line column to column 80 and activates single-edge-line mode. It is able to override a multiple-edge-line or background-color-edge mode set in Notepad++ preferences dialog.
Change Single-Edge-Line Column
::ConfigSingleEdgeLine npp_console keep sci_sendmsg SCI_GETEDGECOLUMN inputbox "Input edge column" : "Edge column" : $(MSG_RESULT) sci_sendmsg SCI_SETEDGECOLUMN $(INPUT) sci_sendmsg SCI_SETEDGEMODE EDGE_LINEThis script opens an input box where users can change the single-edge-line column. The current column is shown as default value. When the user closes the box, the provided value is set as the new column and single-edge-line mode is activated.
Turn on Single-Edge-Line Mode
::SingleEdgeLineOn npp_console keep sci_sendmsg SCI_SETEDGEMODE EDGE_LINEThis script activates single-edge-line mode with its current settings.
Turn on Multiple-Edge-Line Mode
::MultipleEdgeLinesOn npp_console keep sci_sendmsg SCI_SETEDGEMODE EDGE_MULTILINEThis script activates multiple-edge-line mode with its current settings.
Turn on Backgound-Color-Edge Mode
::BackgroundEdgeOn npp_console keep sci_sendmsg SCI_SETEDGEMODE EDGE_BACKGROUNDThis script activates background-color-edge mode with its current settings.
Turn all Edges off
::EdgesOff npp_console keep sci_sendmsg SCI_SETEDGEMODE EDGE_NONEThis script deactivates all edges.
Word-Wrap Selected Text at Single-Edge-Line
::WrapSelectedLinesAtEdge npp_console keep set local $(EdgeModeSingleLine) ~ EDGE_LINE sci_sendmsg SCI_GETEDGEMODE if $(MSG_RESULT) != $(EdgeModeSingleLine) then set local $(LinePixelWidth) = 0 goto :DoWrap endif sci_sendmsg SCI_GETEDGECOLUMN set local $(LineCharWidth) ~ $(MSG_RESULT) + 1 set local $(TemplateStr) = W set local $(Cnt) = 2 :ForLoopStart if $(Cnt) > $(LineCharWidth) goto :ForLoopEnd set local $(TemplateStr) = $(TemplateStr)W set local $(Cnt) ~ $(Cnt) + 1 goto :ForLoopStart :ForLoopEnd sci_sendmsg SCI_TEXTWIDTH STYLE_DEFAULT "$(TemplateStr)" set local $(LinePixelWidth) = $(MSG_RESULT) :DoWrap sci_sendmsg SCI_TARGETFROMSELECTION sci_sendmsg SCI_LINESSPLIT $(LinePixelWidth)This script provides a fixed version of the “word-wrap at single-edge-line” feature. As the original one, it word-wraps at the right edit window border if edge mode is not set to single line. This script could be assigned to the
Ctrl+Ikeyboard shortcut in order to replace the buggy built-in version of Notepad++. -
