markdown 代码中的行长度

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 代码中的行长度相关的知识,希望对你有一定的参考价值。

A lot of coding standards have an opinion regarding line-length.
Some often recuring lengths are 80 and 120 characters.

It is commonly stated that the 80 character limit original existed because of terminal screens.
Since we don't live in this world anymore, the 120 character limit becomes more and more the standard.

This statement isn't entirely correct, that is to say, it's even worse than that. 
The common coding standard is a result of the IBM's 1928 80 column punched card format.

![IBM Punchcard](http://i.stack.imgur.com/XvPKy.jpg)

<sup>source: http://softwareengineering.stackexchange.com/questions/148677</sup>

There are, however, other reasons beside punchcards, terminals and screen size that come into play. 

> It turns out that the subconscious mind is energized when jumping to the next line (as long as it doesn’t happen too frequently, see above bullet point). At the beginning of every new line the reader is focused, but this focus gradually wears off over the duration of the line (“Typographie”, E. Ruder).
> 
> In order to avoid the drawbacks of too long and too short lines, but still energize your readers and keep them engaged, we suggest keeping your text within the range of 50-75 characters per line.
> 

<sup>source: http://baymard.com/blog/line-length-readability</sup>

Besides this, code is not just displayed in the Editor, it is displayed in Diff-tools, (browser based) code review tools, emails, bug trackers, etc. People with laptops with small screens will work on the same code-base as user with "broad" screens.

Wider lines means more scrolling in a lot of such tools as "line-wrap" is not universally implemented.

When stating "120 works for me", effectively you are not taking other scenario's into account than your current working scenario. It is basically a poorly disguised

![cheap cop out](https://blog.codinghorror.com/content/images/uploads/2007/03/6a0120a85dcdae970b0128776ff992970c-pi.png)

There is a difference between code, markup and generated output. For code the 80-ish (50-75 characters + indentation whitespace) is more important than for markup, as code is more frequently read and updated than docs.

以上是关于markdown 代码中的行长度的主要内容,如果未能解决你的问题,请参考以下文章

使用tidyr将字符串长度不均匀的行拆分为R中的列[重复]

markdown AVNLIPPP - 流行的PHP项目中的平均变量名称长度

限制ansible控制台输出中的行长度

使Angular mat-table中的行数长于dataSource的长度

如何将每个给定长度的行的 Bigquery 表提取到 Google Storage 中的 csv 文件?

Markdown温故知新:详解七大标准语法