(2012-04-03) Semantic Linefeeds

Semantic Linefeeds. Let me share what I teach them about “semantic linefeeds,” then I will reveal its source. (see Semantic Line Breaks)

I ask students whether or not the Sphinx text files in their project will be read by end-users. If not, then I encourage students to treat the files as private “source code” that they are free to format semantically. Instead of fussing with the lines of each paragraph so that they all end near the right margin, they can add linefeeds anywhere that there is a break between ideas.

And your version-control system will love semantic linefeeds. Have you ever changed a few words at the beginning of a paragraph, only to discover that version control now thinks the whole text has changed?

Text editors are very good at manipulating lines — so when each sentence is a contiguous block of lines, your editor suddenly becomes a very powerful mechanism for quickly rearranging clauses and ideas.

So where did I learn the trick?

I could not be any happier to discover that my inspiration is none other than Brian Kernighan!

He published “UNIX for Beginners” [PDF] as Bell Labs Technical Memorandum 74-1273-18 on 29 October 1974. It describes a far more primitive version of the operating system than his more famous and more widely available “UNIX for Beginners — Second Edition” from 1978

  • Hints for Preparing Documents
  • Most documents go through several versions (always more than you expected) before they are finally finished. Accordingly, you should do whatever possible to make the job of changing them easy.
  • First, when you do the purely mechanical operations of typing, type so subsequent editing will be easy. Start each sentence on a new line. Make lines short, and break lines at natural places, such as after commas and semicolons, rather than randomly. Since most people change documents by rewriting phrases and adding, deleting and rearranging sentences, these precautions simplify any editing you have to do later.
    — Brian W. Kernighan, 1974

Note how Pythonic his advice sounds — he replaces the fiction of “write-once” documents with a realistic focus on making text that is easy to edit later!


Edited:    |       |    Search Twitter for discussion