Top
Best
New

Posted by Bogdanp 6 days ago

Semantic Line Breaks (2017)(sembr.org)
97 points | 66 commentspage 2
jsdalton 3 days ago|
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 3 days ago|
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 3 days ago||
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 3 days ago|
I think you’ve got things back to front. Semantic line breaks improves diffing.
admko 3 days ago||
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 3 days ago||
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 3 days ago|
Many editors allow reformatting a user-selected portion or the current line, and some even the current sentence, with a simple keyboard shortcut.
Thorrez 2 days ago||
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 3 days ago||
Wonder if any linters know about this convention.
dorianmariecom 3 days ago||
i thought this was for ruby and javascript and this would be really cool.

automated formatting including newlines, would be great.

huflungdung 3 days ago|
[dead]