Top
Best
New

Posted by Bogdanp 9/7/2025

Semantic Line Breaks (2017)(sembr.org)
99 points | 68 commentspage 2
jsdalton 9/10/2025|
I’ve often thought this would be useful for version control and change review, since it allows diffs to be a lot less noisy. I’m imagining how much easier it would be to review a PR with significant README edits if the file was already structured with semantic line breaks.

I’ve previously had the above thought and applied it to the end of sentences, but the idea of introducing them at the level of semantic thought had not occurred to me. But if this is where we’re going I’d start to wish for indentation possibilities. I’ve do this frequently with SQL statements, introducing both line breaks and indentations to provide a visual structure that mimics the semantic structure of clauses and the details they contain.

meatmanek 9/10/2025|
Indeed. Edits show up as a -/+ on just the sentence or clause that has changed. Contrast with hard-wrapped text, where a single word change towards the beginning of a paragraph can cause the entire paragraph to be replaced in the diff view, as things reflow.
tpoacher 9/10/2025||
There is a very good technical argument for NOT using "semantic" line breaks when editing markup source code, especially of the "hardwrap" variety, and that is the ability to easily diff two versions of the same document, e.g. when comparing latex git commits.

Anything that reorganises the sentence around for the sake of maintaining justification, completely destroys any meaningful diff from taking place.

And ideally your editor should support both hard and soft wrapping, so that aesthetics of wrapping shouldn't be a big issue.

And I say this as a fan of hardwrapping text.

chrismorgan 9/10/2025|
I think you’ve got things back to front. Semantic line breaks improves diffing.
tpoacher 9/16/2025||
only if the individual lines aren't shifted about / re-justified, and it's only a matter of adding a new line in between existing lines. But with prose (like latex) this is rarely the case. A single word might rejustify the whole paragraph. So suddenly instead of diff showing you a single word change, it flags the whole paragraph.
admko 9/10/2025||
I made a command-line tool [0] powered by Transformer models that performs semantic linebreaks to breaks lines in a text file at semantic boundaries. It supports multiple file types including LaTeX, Markdown, and plain text, with automatic file type detection.

[0]: https://github.com/admk/sembr

Thorrez 9/10/2025||
If your editor auto reflows the text, that will conflict with this, by erasing line breaks you inserted.

This is imposing an 80-character line length limit. With a line length limit, I want an editor to reflow my text so I don't have to do the line length limit manually.

layer8 9/10/2025|
Many editors allow reformatting a user-selected portion or the current line, and some even the current sentence, with a simple keyboard shortcut.
Thorrez 9/11/2025||
Reflowing the current line won't work. If I delete a word, I need the next line's text to be flowed up to join with the current line. And that might require reflowing of subsequent lines as well.

Reflowing the current sentence won't work, because this style involves inserting semantic line breaks in certain places within a single sentence.

Reformatting a user selected portion is going to take more effort on my part. Currently my editor reflows the entire file every time the file is saved; I don't have to think about which part to reflow.

pabs3 9/10/2025||
Wonder if any linters know about this convention.
dorianmariecom 9/10/2025||
i thought this was for ruby and javascript and this would be really cool.

automated formatting including newlines, would be great.

huflungdung 9/10/2025|
[dead]