<?xml version='1.0' encoding='utf-8' ?>

<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>From the Mind of Trevor Stone</title>
  <link>https://flwyd.dreamwidth.org/</link>
  <description>From the Mind of Trevor Stone - Dreamwidth Studios</description>
  <lastBuildDate>Thu, 30 Apr 2020 05:29:31 GMT</lastBuildDate>
  <generator>LiveJournal / Dreamwidth Studios</generator>
  <lj:journal>flwyd</lj:journal>
  <lj:journaltype>personal</lj:journaltype>
  <image>
    <url>https://v2.dreamwidth.org/10935620/2740657</url>
    <title>From the Mind of Trevor Stone</title>
    <link>https://flwyd.dreamwidth.org/</link>
    <width>100</width>
    <height>100</height>
  </image>

<item>
  <guid isPermaLink='true'>https://flwyd.dreamwidth.org/392000.html</guid>
  <pubDate>Thu, 30 Apr 2020 05:29:31 GMT</pubDate>
  <title>conjoin: A Vim Plugin for Continuation Characters</title>
  <link>https://flwyd.dreamwidth.org/392000.html</link>
  <description>As an avowed introvert, I took the opportunity of the new fewer-social-commitment world of coronavirus stay-home orders to do some fun programming on personal projects, like my &lt;a href=&quot;https://github.com/flwyd/curse&quot;&gt;Elizabethan curse generator&lt;/a&gt;.  While working on &lt;kbd&gt;bash&lt;/kbd&gt; and &lt;kbd&gt;Tcl&lt;/kbd&gt; implementations I discovered that &lt;kbd&gt;vim&lt;/kbd&gt;, my favorite text editor, did not automatically remove line continuation characters when performing a join command.  In my case, I had copied an array of quoted strings from Python into a shell script, which doesn&apos;t need quoted strings, and wanted to realign the declaration to fit nicely in 80 columns, like so: &lt;blockquote&gt;&lt;kbd&gt;noun=(apple-john baggage barnacle bladder boar-pig bugbear bum-bailey \&lt;br /&gt;  canker-blossom clack-dish clotpole coxcomb codpiece crutch cutpurse \&lt;br /&gt;  death-token dewberry dogfish egg-shell flap-dragon flax-wench flirt-gill \&lt;br /&gt;  foot-licker fustilarian giglet gudgeon gull-catcher haggard harpy hedge-pig \&lt;br /&gt;  hempseed horn-beast hugger-mugger jack-a-nape jolthead lewdster lout \&lt;br /&gt;  maggot-pie malignancy malkin malt-worm mammet manikin measle minimus minnow \&lt;br /&gt;  miscreant moldwarp mumble-news nut-hook pantaloon pigeon-egg pignut puttock \&lt;br /&gt;  pumpion rabbit-sucker rampallion ratsbane remnant rudesby ruffian scantling \&lt;br /&gt;  scullion scut skainsmate snipe strumpet varlot vassal waterfly whey-face \&lt;br /&gt;  whipster wagtail younker)&lt;/kbd&gt;&lt;/blockquote&gt;Unfortunately, the &lt;kbd&gt;J&lt;/kbd&gt; command in &lt;kbd&gt;vim&lt;/kbd&gt; leaves those trailing backslashes (which mean &quot;the command keeps going on the next line&quot;) in the middle of the combined line.  After a bunch of Googling, I determined that there wasn&apos;t a &lt;kbd&gt;vim&lt;/kbd&gt; setting to do so, and nobody had written a plugin for it either.&lt;br /&gt;&lt;br /&gt;So of course I decided that extra home-bound free time meant it was time to learn how to write a &lt;kbd&gt;vim&lt;/kbd&gt; plugin so that I could change the behavior of the line-joining commands.  A couple coworkers mentioned that such a plugin would be even more useful if it could merge strings when joining as well (resulting in &lt;kbd&gt;&quot;lorem ipsum&quot;&lt;/kbd&gt; rather than &lt;kbd&gt;&quot;lorem &quot; + &quot;ipsum&quot;&lt;/kbd&gt;).  This in turn provided a great excuse to geek out on programming language details on Wikipedia, &lt;a href=&quot;https://rosettacode.org/&quot;&gt;Rosetta Code&lt;/a&gt; and &lt;a href=&quot;http://99-bottles-of-beer.net/&quot;&gt;99-bottles-of-beer.net&lt;/a&gt;.  &lt;strong&gt;And thus was born &lt;a href=&quot;https://github.com/flwyd/vim-conjoin&quot;&gt;vim-conjoin&lt;/a&gt;&lt;/strong&gt;, a plugin that remaps &lt;kbd&gt;J&lt;/kbd&gt;, &lt;kbd&gt;gJ&lt;/kbd&gt;, and &lt;kbd&gt;:Join&lt;/kbd&gt; to handle continuation breaks and string concatenation.&lt;br /&gt;&lt;br /&gt;This exercise was absolutely a violation of &lt;a href=&quot;https://xkcd.com/1205&quot;&gt;XKCD&apos;s &lt;cite&gt;Is It Worth the Time&lt;/cite&gt;&lt;/a&gt; graph: I spent the better part of two weekends, plus a few evenings, implementing and testing this plugin (mostly testing).  It will, in my lifetime, perhaps save me an hour of work.  So hopefully other &lt;kbd&gt;vim&lt;/kbd&gt; users find it useful, too.&lt;br /&gt;&lt;br /&gt;As with any personal programming project, the time wasn&apos;t entirely wasted, of course.  The &lt;em&gt;next&lt;/em&gt; time I want to write a &lt;kbd&gt;vim&lt;/kbd&gt; plugin I&apos;ll have a much better idea of what I&apos;m doing.  And I learned more in a couple weeks about &lt;kbd&gt;vim&lt;/kbd&gt; than I&apos;ve learned in most individual years in the last two and a half decades I&apos;ve used the editor.  (Though it&apos;s going to take me awhile to remember to put &lt;kbd&gt;call&lt;/kbd&gt; before function invocations and I&apos;m forever forgetting the &lt;kbd&gt;l:&lt;/kbd&gt; and &lt;kbd&gt;a:&lt;/kbd&gt; prefixes on local and argument variables.)  And the Wikipedia adventures led me to finally read up on &lt;a href=&quot;https://en.wikipedia.org/wiki/INTERCAL&quot;&gt;INTERCAL&lt;/a&gt; a famously obtuse parody language, and &lt;a href=&quot;https://en.wikipedia.org/wiki/LOLCODE&quot;&gt;LOLCODE&lt;/a&gt;, a lolcat-inspired esoteric programming language that I wish I&apos;d heard about in 2007 when it was announced.  (LOLCODE unfortunately seems to have been abandoned; the language author hasn&apos;t responded to a &lt;a href=&quot;https://github.com/justinmeza/lolcode-spec/issues/11&quot;&gt;2018 proposal for array (&lt;kbd&gt;BUKKIT&lt;/kbd&gt;) syntax&lt;/a&gt;.)  And &lt;em&gt;that&lt;/em&gt; gave me an idea for an esoteric language of my own that I hope to work out during the remainder of quarantine time…&lt;br /&gt;&lt;br /&gt;You do you.  And make sure you&apos;ve got an unnecessarily polished tool while doing so.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=flwyd&amp;ditemid=392000&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://flwyd.dreamwidth.org/392000.html</comments>
  <category>vim</category>
  <category>programming</category>
  <category>editor</category>
  <category>covid-19</category>
  <category>coronavirus</category>
  <lj:music>KGNU - Reggae Transfusion</lj:music>
  <lj:mood>quixotic</lj:mood>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
</channel>
</rss>
