Semantic Line Breaks

Although I can’t find it on the sum total of human knowledge, the World Wide Web, I have a memory that one of the Enlightened Unix Masters, Dennis Ritchie or Brian Kernighan maybe, wrote some tips about how to format written input for the venerable troff typesetting system.

xkcd modified to make even more sense

The Sage wrote that shorter pieces of a sentence, a clause or so, was better than one sentence per line, or even one paragraph per line. The reasoning was that when editing, the clause or short sentence is the unit that the (human) editor changes or moves around. The Sage wrote this observation well before the days of “WYSIWYG” word processors, where what used to be a “line break” now formats as “end of paragraph”.

The GNU Groff Manual has the same sort of recommendations, only more prosaically worded:


Here are a few hints for preparing text for input to GNU troff.

  • First, keep the input lines short. Short input lines are easier to edit, and GNU troff packs words onto longer lines anyhow.
  • In keeping with this, it is helpful to begin a new line after every comma or phrase, since common corrections are to add or delete sentences or phrases.
  • End each sentence with two spaces—or better, start each sentence on a new line. GNU troff recognizes characters that usually end a sentence, and inserts inter-sentence space accordingly.
  • Do not hyphenate words at the end of lines—GNU troff is smart enough to hyphenate words as needed, but is not smart enough to take hyphens out and join a word back together. Also, words such as “mother-in-law” should not be broken over a line, since then a space can occur where not wanted, such as “mother- in-law”.

The troff hints for preparing text roughly describe a style of (pre-formatting and layout) text arrangement called Semantic Line Breaks. I did not know until now that someone had bothered to write up such a concise and complete description. It’s worth a read. I’ve been using the vaguely remembered tips from an Enlightened Master to motivate how I arrange markdown formatted text for this very blog. Surprisingly, I had come to very much the same rules as the Semantic Line Breaks person.

Some of the rules just make the markdown text easier to proofread - putting hyperlinks at the end of a line, or on their own lines does enhance readability. The surprising thing about semantic line breaks is that editing text feels and works differently. Perhaps I feel this way because I use vim, maybe semantic line breaks work for me because of the particular text editor I use. I’ve certainly seen arguments that incredibly long “lines” (not lines at all, but paragraphs, really) are the way to arrange pre-formatted text. This strikes me as utterly relying on editors and other text fields behaving a particular way, so oh well…

Text arranged with semantic line breaks makes it a lot easier to rearrange the ideas expressed by the text. Sentences might be spread out over two or more lines, but vim has block text selection, making it easy to highlight sentences, then move them (D or Y to copy, p to paste back in). Long sentences with line breaks at punctuation or clauses, become far easier to rewrite into shorter sentences. Rewriting a sentence with clauses on separate lines also becomes easier.

I was inspired to write this post because of xkcd comic #1285 showing people fighting about number of spaces after a period. It took me forever, this post spent 28 months in draft status.