{"id":1224,"date":"2013-08-07T14:49:21","date_gmt":"2013-08-07T13:49:21","guid":{"rendered":"http:\/\/www.stenyak.com\/?p=1224"},"modified":"2013-08-07T14:49:21","modified_gmt":"2013-08-07T13:49:21","slug":"in-defense-of-unformatted-source-code-breakindent-for-vim","status":"publish","type":"post","link":"https:\/\/www.stenyak.com\/?p=1224","title":{"rendered":"In defense of unformatted source code &#8211; breakindent for vim"},"content":{"rendered":"<p>Everyone knows that Opera is better than Firefox, \u00a0Vim+Bash is better than any IDE, and 4-space indenting is better than tabulators. Having established those undisputed facts of life, let&#8217;s revisit some common fuel for flame wars: the mighty <strong>80 character line limit<\/strong>.<\/p>\n<p>&nbsp;<\/p>\n<div id=\"attachment_1238\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/www.stenyak.com\/wp-content\/uploads\/2013\/08\/FortranCardPROJ039.agr_.jpg\"><img aria-describedby=\"caption-attachment-1238\" loading=\"lazy\" class=\"size-medium wp-image-1238 \" alt=\"80x10 &quot;IBM Card&quot; from 1928\" src=\"https:\/\/www.stenyak.com\/wp-content\/uploads\/2013\/08\/FortranCardPROJ039.agr_-300x144.jpg\" width=\"300\" height=\"144\" srcset=\"https:\/\/www.stenyak.com\/wp-content\/uploads\/2013\/08\/FortranCardPROJ039.agr_-300x144.jpg 300w, https:\/\/www.stenyak.com\/wp-content\/uploads\/2013\/08\/FortranCardPROJ039.agr_-768x369.jpg 768w, https:\/\/www.stenyak.com\/wp-content\/uploads\/2013\/08\/FortranCardPROJ039.agr_.jpg 800w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1238\" class=\"wp-caption-text\">Fortran code punched into a 80 x 10 <a href=\"http:\/\/www-03.ibm.com\/ibm\/history\/history\/year_1928.html\">IBM Card<\/a> from 1928<\/p><\/div>\n<p>&nbsp;<\/p>\n<p>Some people propose\u00a080\u00a0chars, others\u00a079, 100,\u00a0120, 132\u00a0, and many values in between.<\/p>\n<p>Some people propose it should be a\u00a0<em>soft limit<\/em>\u00a0(meaning you can freely ignore in rare cases), while others set pre-commit hooks to stop any infringing line from reaching repositories.<\/p>\n<p><strong>None of this really matters<\/strong>.<\/p>\n<div style=\"clear: both;\"><\/div>\n<p>The 80 character line limit, originated by hardware limits back when <a href=\"http:\/\/en.wikipedia.org\/wiki\/VT100\">computer terminals were only 80 chars wide<\/a>, or <a href=\"http:\/\/en.wikipedia.org\/wiki\/Punched_card#IBM_80-column_punched_card_formats_and_character_codes\">even further back in time<\/a>, is said to provide many <strong>advantages<\/strong>. To name a few:<\/p>\n<ul>\n<li>Better readability when opening two <strong>files side by side<\/strong> (for example, a diff)<\/li>\n<li>Quicker to read (same reason why newspapers use many columns of text, instead of page-wide paragraphs:\u00a0<strong>human brain scans text faster<\/strong> that way).<\/li>\n<li>It forces you to extract code into separate functions, in order to <strong>avoid too many nesting<\/strong> levels.<\/li>\n<li>It prevents you from choosing overly <strong>long symbol names<\/strong>, which hurt readability.<\/li>\n<li>Etc.<\/li>\n<\/ul>\n<p>I propose that those advantages are real and desirable, but should not be achieved through arbitrary line length limits. On the contrary, I propose that <strong>coders should not waste time formatting<\/strong> their source code: their tools should do it when possible. After all, we use text editors, not word processors!\u00a0The problem is that, unfortunately, most text editors are too dumb.<\/p>\n<blockquote>\n<p style=\"text-align: center;\"><strong>Fix the editors, and you fix the need for line length limits<\/strong>.<\/p>\n<\/blockquote>\n<p>&nbsp;<\/p>\n<p>If you edit your code in vim, you&#8217;re in luck, thanks to the <a href=\"https:\/\/retracile.net\/wiki\/VimBreakIndent\">Breakindent functionality<\/a>.\u00a0Here&#8217;s some side-by-side comparisons of <strong>80-char line limit<\/strong> vs. <strong>unformatted text with\u00a0BreakIndent<\/strong> enabled:<\/p>\n<div align=\"aligncenter\">\n<div id=\"attachment_1226\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2013\/08\/80x35.png\"><img aria-describedby=\"caption-attachment-1226\" loading=\"lazy\" class=\" wp-image-1226    \" alt=\"80x35\" src=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2013\/08\/80x35.png\" width=\"600\" height=\"244\" \/><\/a><p id=\"caption-attachment-1226\" class=\"wp-caption-text\"><span style=\"color: #808080;\"><em>(left: 80-char \u00a0 \u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 right: breakindent)<\/em><\/span><\/p>\n<h3><strong>Traditional terminal size<\/strong>:<\/h3>\n<p>Resizing your terminal to <strong>exactly<\/strong> 80 chars wide, both cases look pretty similar. Nothing to see here, move along.<span style=\"font-size: 13px; line-height: 19px;\"><br \/><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><\/p><\/div>\n<p>&nbsp;<\/p>\n<div style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2013\/08\/208x16-26.png\"><img loading=\"lazy\" class=\"  \" alt=\"208x16-26\" src=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2013\/08\/208x16-26.png\" width=\"600\" height=\"242\" \/><\/a><p class=\"wp-caption-text\"><span style=\"color: #808080;\"><em>(top: 80-char \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 bottom: breakindent)<\/em><\/span><\/p>\n<h3><strong>Wide terminal<\/strong>:<\/h3>\n<p>If you want to edit just one file, an 80-char limit will <strong>waste the rightmost half<\/strong> of your screen (or more).<\/p>\n<p>&nbsp;<\/p>\n<p><\/p><\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div id=\"attachment_1227\" style=\"width: 444px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2013\/08\/40x50.png\"><img aria-describedby=\"caption-attachment-1227\" loading=\"lazy\" class=\"wp-image-1227   \" alt=\"40x50\" src=\"http:\/\/www.stenyak.com\/wp-content\/uploads\/2013\/08\/40x50.png\" width=\"434\" height=\"480\" \/><\/a><p id=\"caption-attachment-1227\" class=\"wp-caption-text\"><span style=\"color: #808080;\"><em> (left: 80-char \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 right: breakindent)<\/em><\/span><\/p>\n<h3><strong>Narrow terminal<\/strong>:<\/h3>\n<p>If you&#8217;re three-way merging (or need to keep code aside for a moment, etc) those 80 chars will either <strong>wrap around or disappear<\/strong> from view, making the code harder to read.<\/p>\n<p>&nbsp;<\/p>\n<p><\/p><\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<p><strong>All in all<\/strong>: when compared to an editor featuring smart indenting, the 80-char lines <strong>artificially limit<\/strong> how you can resize your own windows, with <strong>no appreciable gain<\/strong>, and in most cases forcing you to <strong>waste many pixels<\/strong> of your carefully chosen 27&#8243; dual-screen coding setup.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Everyone knows that Opera is better than Firefox, \u00a0Vim+Bash is better than any IDE, and 4-space indenting is better than tabulators. Having established those undisputed facts of life, let&#8217;s revisit some common fuel for flame wars: the mighty 80 character line limit. &nbsp; &nbsp; Some people propose\u00a080\u00a0chars, others\u00a079, 100,\u00a0120, 132\u00a0, and many values in between. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[13,24],"_links":{"self":[{"href":"https:\/\/www.stenyak.com\/index.php?rest_route=\/wp\/v2\/posts\/1224"}],"collection":[{"href":"https:\/\/www.stenyak.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stenyak.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stenyak.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stenyak.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1224"}],"version-history":[{"count":0,"href":"https:\/\/www.stenyak.com\/index.php?rest_route=\/wp\/v2\/posts\/1224\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.stenyak.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stenyak.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stenyak.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}