Wrapping lines

Common line lengths

Lines are often wrapped at multiples of 8 (the traditional length of a tab). Commons values are:

Note that those numbers only refer to the visible columns. The newline character (or a carriage return before it) are not included in the number. Also, tabs take only 1 byte of space, but count as 8 columns (or a different number, depending on the convention). Similarly, regular non-ASCII characters encoded in UTF-8 take multiple bytes of space, but count as 1 column. This means that you cannot rely on the number of bytes to determine the number of columns that a line takes.

=> https://suckless.org/coding_style/ | https://peps.python.org/pep-0008/#maximum-line-length

The ch unit in web typography

I've read somewhere that prose should be typeset with a width of about 2 to 3 alphabets (i.e. the width of a string running from "a" to "z"). I have often used a max-width of "65ch" in my CSS stylesheets for this reason. (65 is exactly 2.5 times 26, the number of letters in the alphabet.) The unit "ch" is short for "character" and represents the width of the character "0" in the current font. If that width cannot be determined, the unit is supped to be equal to 0.5em. So when I don't want to make the max-width depend on the current font, I like to use "32rem" instead.

=> MDN on CSS length units

Tools

I like to use GNU nano to edit text files. With "-J80" (which you can make permanent with "set guidestripe 80" in your nanorc file), nano highlights the 80th column. So in order to make your lines at most 79 columns wide, make sure that the last character just touches the highlighted stripe, but does not lie on it.

With "-r72" and "-M" (which you can make permanent with "set fill 72" and "set trimblanks" in your nanorc file), you can justify a paragraph with ^J (and the entire document with M-J) to be at most 72 columns wide, which also removes trailing blanks. Leading indentation and comment symbols are automatically recognized in most cases.

This combination of settings -- a marker after 79 columns and automatic justification to 72 columns -- is the easiest way to follow the PEP 8 recommendations.

You can also hard-wrap lines outside of a text editor with the fold(1) and fmt(1) tools. Make sure you know how they count line lengths and how they treat trailing whitespace before you use them.

Proxy Information
Original URL
gemini://dkalak.de/tech/wrapline.gmi
Status Code
Success (20)
Meta
text/gemini; lang=en
Capsule Response Time
114.757854 milliseconds
Gemini-to-HTML Time
0.387301 milliseconds

This content has been proxied by September (ba2dc).