Skip to content

Latest commit

 

History

History
54 lines (37 loc) · 2.75 KB

style-maxlen.md

File metadata and controls

54 lines (37 loc) · 2.75 KB

Maximum line length

We follow a hard line wrapping at 120 cpl (characters per line), and soft line wrapping at 80 cpl.

What this means is that editors should be configured to show two rulers:

  • at 80 cpl - a limit we TRY not to surpass
  • at 120 cpl - a limit we CANNOT surpass

In very very rare cases e.g. regular expressions, we need/want to go above 120 cpl, and that's fine. Just append a comment to the end of the line to please the editorconfig-checker e.g. # editorconfig-checker-disable-line or // editorconfig-checker-disable-line.

For reference, there are less than 50 instances in yplatform of such exceptions as of 2021-08-18. Very very few that is.

But why?

TL;DR: shorter lines = better comprehension.

Reading code is not the same as reading prose, yes. But that doesn't imply that all reasearch is redundant or that the former becomes a false statement. So while typography findings (mostly focused on prose) shouldn't be taken ad-literam (we engineers like strict limits), it is important not to ignore them. That's why while the findings point at really really short lines, while history had us at 80 cpl (punchcards), code with all its keywords and indentation could be given some slack, but not deregulated.

Anyone to back you up?

Wikipedia: Researchers have suggested that longer lines are better for quick scanning, while shorter lines are better for accuracy. Longer lines would then be better suited for cases when the information will likely be scanned, while shorter lines would be appropriate when the information is meant to be read thoroughly. One proposal advanced that, in order for on-screen text to have the best compromise between reading speed and comprehension, about 55 cpl should be used.

Read why Daniel Stenberg (curl maintainer) is an 80-column purist. Comments on HN.

Read why 40-90 cpl is an optimal line length, here and here.

Because displays have grown in size and resolution in the last few years. Eyes haven't.

If you think 80 is tight, try 36 cpl like Breck Yunit! Because "thinner columns leave you with more energy for more editing passes. More editing passes improves quality". "To write faster, I need to read faster."

"The 66-character line (counting both letters and spaces) is widely regarded as ideal." Robert Bringhurst in The Elements of Typographic Style