Is it possible to implement an actual wrap at the wrap indicator, instead of just the vertical line? I am only using Linux now, but I used this feature extensively in TextPad in Windows.
Do you mean "wrap" or "break" ? Wrap is a display only thing and happens only at the right edge of the screen. Break is actually modifying the text to include line breaks and happens at the long line setting.
I'm not sure either, but I think the question could be rephrased as:
Can the column boundary marker actually enforce the column limit, instead of just visually indicating where a break should ideally occur?
So, imagine the marker had the same effect as manually narrowing the main window's right border, e.g.
<img alt="geany-hard-break-at-visual-line-break-col" src="https://github.com/geany/geany/assets/59004801/57ef738c-7612-4d72-bddc-7d9d150e3a25">
@rdipardo
Can the column boundary marker actually enforce the column limit, instead of just visually indicating where a break should ideally occur?
Is that not `Document->Line breaking`?
I'm afraid your diagram was more confusing than helpful, the lines you have noted as "ok" are wrapped (see the 180 degree arrow) so they are longer than the marker but by coincidence wrapping has hidden that fact, whilst the "bad" line has a visible exceedance because it hasn't wrapped?
Note, line breaking does not break lines when typing adds characters before the column limit, even if that pushes characters on the line past the limit.
Why?
Its complicated, let me show why.
In the following | means the breaking column and the successive snippets separated by blank lines are the progressive results of typing the x characters.
Naive line breaking inserting a newline before the last word when the line exceeds the limit:
``` aaa bbb ccc| ddd |
xaaa bbb | ccc | ddd |
xxxxxaaa | bbb | ccc | ddd |
```
oops, probably wanted the sequence:
``` xaaa bbb | ccc ddd |
xxxxxaaa | bbb ccc | ddd | ```
This is called "reflow" as provided by `Edit->Format->Reflow Lines/Block` and is a fine thing for text files if limited to a paragraph.
But as soon as it anything other than plain text, even mostly text like markdown it can break the markup, eg consider a line containing a `#` character, if it happens to reflow to the start of a line suddenly your paragraph has a heading in the middle of it!
And its even worse with code, although many languages don't care about embedded line breaks most of the time, all do care inside string quotes, and there are even more subtle issues with some languages:
``` starting with and typing x a = 1 + 2|
Python xa = 1 + | 2
Go xxxa = 1 | + 2 | ```
The python result is illegal, but more insidiously the Go example is legal, but assigns 1 to the variable and calculates the expression 2 as a separate statement that does nothing.
So since simple automatic line breaking when typing before the limit is so often wrong Geany does not provide it, although it provides the facility to break when typing past the limit when the user has immediate visibility of the result and can fix any problems. Also the user can manually apply reflow.
Geany is the best Linux text editor because of it's simplicity and versatility. But, I am also using Windows TextPad in Wine, which is a text and code editor with numerous features not available in any Linux software, but the preference in Linux is Geany.
@ineuw Does this GIF illustrate the kind of feature you're asking about?
![vim-tw=45-colorcoumn=45](https://github.com/geany/geany/assets/59004801/3a943591-bb81-41c8-a54b-a5249...)
[!Note] The demo assumes the [`textwidth`](https://vimhelp.org/options.txt.html#%27tw%27) (`tw`) and [`colorcolumn`](https://vimhelp.org/options.txt.html#%27cc%27) (`cc`) options are set to the same value.
This is amazing yes it's perfect.ty.
@ineuw @rdipardo as I said above, is the functionality illustrated in the video not `Document->Line breaking` ??
@elextr how stupid of me. Yes, it is exactly that. Please accept my apologies.
Closed #3718 as resolved.
@elextr
the functionality illustrated in the video not `Document->Line breaking`??
My only success was with v1.38 and I installed v2.00 on another Linux Mint installation.
Unfortunately, the line breaking no longer works in either version. I read the documentation closely, but I must have missed something. There is no information on what are the required settings to make it work.
Can you please advise what I am doing wrong?
Reopened #3718.
Settings are `Preferences->Editor->Featrues->Line Breaking Column` which is overridden by `Project->Properties->Editor->Line breaking Column` if a project is open. Line breaking is turned on by _per document_ by `Document->Line Breaking`. It is remembered whilst the file is open even if Geany is closed and reopened, but is forgotten when the file is closed.
@elextr, your instructions are perfectly clear, but the line doesn't break, as it did when I tried it back in December 14. I am now using 1.38 in LMC 21.3. The attached contains 3 long text paragraphs for testing.
[wrap-test.txt](https://github.com/geany/geany/files/13933649/wrap-test.txt)
I opened your `wrap-test.txt` in Geany 2.0 and turned on `Document->Line Breaking`, typed space before "Chamber" and it breaks before "Princes". I did the same in Geany 1.38 with exactly the same result. This is exactly what is expected. All with default line break values of 72 and no project. Please provide a set of steps to reproduce.
I followed the identical steps. Original settings of 72 chars, ![2024-01-14 19-53-44 same setup and file](https://github.com/geany/geany/assets/10367016/a1162458-1e85-4fc5-ad65-b4b21...)
However, I will purge and install fresh, testing each step. Using 1.38 from the LMC repository. I am just as curious about what went wrong.
Your image shows you have turned off the long line marker, but if I turn it off it still works in both 1.38 and 2.0, however are you sure you are typing _after_ column 72 (since you don't have the marker)?.
Yes, I understood what is happening. Wrap only occurs when typing counting the column position, but not when pasting.
I suggest that when the break feature be applied to the tab or window, wrapping any text opened or pasted until it's switched off by the user. The current method is very limited, cumbersome, and requires retyping pasted text.
I am closing the issue, because my work is pasting back and forth between Geany and Wikisource/Wikipedia.
The `Line Breaking` functionality is indeed limited, it is not dynamic reflow for all the reasons I noted [above](https://github.com/geany/geany/discussions/3718#discussioncomment-7837294). Perhaps in your use-case you might be better off doing `Edit->Format->Reflow lines/block` on a regular basis rather than single line breaking so the whole paragraph is handled.
Also be aware when gathering data from random websites that counting columns on reflow does not account for combining characters so `öööööööööööööööö` will count as twice as many "columns" as glyphs. Same for version selectors on emoji and for double wide Asian characters (which count less than the glyph width).
We are confused about what is wanted to be accomplish. Having both a line break and a line wrap feature is confusing.
Wrapping the text to a selected width setting based on the character count is the logical option. If it's set to 68 characters, that would be the correct width regardless of the columns. The current wrap width is a calculated value based on the display. Allowing user control of the display width and turning it off an on from the toolbar would be a most welcome solution.
This is a feature that only exists in TextPad in Windows. Windows Notepad++ can wrap only as Geany.
Ok, well, the very first thing I asked was did you mean wrap or break :wink: because you are not the first person to get them confused.
Windows Notepad++ can wrap only as Geany.
Wrapping is performed by the Scintilla editing widget both Geany and Notepad++ use. Scintilla does not offer wrapping at any position other than the window width, so neither Geany or Notepad offer wrapping at another position. AFAICT Textpad is proprietary software so its unknown what it uses.
Wrapping is actually quite complex (and slow) and has to be performed using a width in pixels, so I can see why Scintilla uses window width, its the only known fixed pixel value it has. As I noted above "columns" is a complex issue when moving beyond ASCII so converting it to pixels is complex, especially if the contents use non mono-spaced fonts or more than one font within the line.
Much thanks for continuing the discussion. I realize the issues involved, and these posts may help others like me searching for solutions. And Textpad is definitely proprietary. I am using it with Wine but would like to replace everything Windows.
It is the window width which sets the word wrap, not scintilla.
But the line break option contains half of the feature by breaking a newly typed line. I am hoping that someone in the future may look at the this script and figure out breaking existing lines as well.
![240125_0740_geany-wrap](https://github.com/geany/geany/assets/10367016/d2a689c9-b830-478f-bebd-a972b...)
It is the window width which sets the word wrap, not scintilla.
Scintilla is the editing widget that provides the edit pane, and as it lays out the lines it is the code that provides the line wrapping, which is purely a display feature and does not change the file contents. Scintilla is a separate project and as noted above is used by other projects including Notepad++. On the Scintilla feature list the maintainer has rejected working on wrapping at a point other than window edge himself, but that does not prevent somebody else contributing it, but until then wrapping will remain at window edge.
Geany provides `Line Breaking`, which adds an actual line end to the file contents. As it does not have access to the display layout that Scintilla does, this is the only way Geany can split lines, and again as it does not have layout information it has to use code point count for positioning. That allows it to use a column count rather than the window edge, but it has the problems noted in several comments above.
Geany also provides `Reflow` which applies to a paragraph (or a multi line selection) and is like line breaking applied to a paragraph (or a multi-line selection). It is not performed continuously as you type because of the cost and the fact that it does not apply to all of a file, even in a text document any pre-styled content (eg code snippets, verse, tables) should not be reflowed, but Geany has no knowledge to control that. It also has issues when applied to non-ASCII text as outlined above. But `Reflow` has a shortcut (default `ctrl+J`) which you could press at any point you want to to reflow your current paragraph.
The upshot is that until "somebody" contributes wrapping to Scintilla, or a suitably controlled continuous reflow to Geany then `ctrl-J` seems your best option.
github-comments@lists.geany.org