Word wrap highlighter creates a second line when text reaches the end of the line on-screen

Hello, this is a minor annoyance with how the word wrap highlighter (add-highlighter buffer/ wrap -word) works and I was wondering if I was doing it wrong or if this is just intended (or unintended) behaviour. It seems to wrap around and create a new (blank) line if the line being wrapped reaches the right end of the screen. This leads to a lot of random blank lines in the middle of my text which can be jarring.

Is there a way to disable this on my end/have it only wrap if the content of the line not including the newline at the end goes past the end of the line displayed on screen?

Example:

Kakoune reserves a cell at the end of each line to represent the newline character. Normally it’s just a space, but if you use the show-whitespaces highlighter you can make it visible. As a result, if you have a line in your buffer that is exactly 80 columns wide (up to the newline), Kakoune will require an 81-column terminal to display it without wrapping or overflow.

Unfortunately, there’s currently no way to configure this behaviour; the wrap highlighter is designed to ensure the entire line is visible on-screen, even the trailing newline.

It looks like you’re hard-wrapping your text rather than relying on the wrap highlighter to keep text visible on-screen. If you reduce the hard-wrap width by a column, that should avoid the problem nicely. Alternatively, rather than hard-wrapping at a particular line-length I use semantic line-breaks to break each sentence into grammatical chunks, which makes prose a lot easier to handle with a line-based editor like Kakoune, and also plays nicely with version-control tools designed for source code, like Git.

2 Likes

Hi, thanks for the info!

I’m not quite sure what you mean by hard-wrapping as opposed to the wrap highlighter? The command I referenced in the original post is the one I used to enable this highlighter, and the docs seem to reference it as soft-wrapping.

“soft-wrapping” means text is automatically wrapped to a new line at the width of the display. Resizing the window typically causes the text to be reflowed, and a newline character is typically used to separate entire paragraphs.

“hard-wrapping” means a newline character is inserted into the file to split text onto a new line. It can be done manually with the Enter key, or automatically as with Kakoune’s :autowrap-enable command. Resizing the window leaves the text wrapped at the same width, and paragraphs are typically separated by a pair of newline characters.

In your screenshot, line 17 ends with “des” and line 18 begins with “données” which seems like the middle of a sentence rather than a paragraph break, so I guess your text is hard-wrapped.

1 Like

Oh yes, it was previously hard wrapped but I was trying to move to using the Kakoune soft wrap functionality.

1 Like