<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dw="https://www.dreamwidth.org">
  <id>tag:dreamwidth.org,2017-01-08:2740657</id>
  <title>From the Mind of Trevor Stone</title>
  <subtitle>… blogging like it's the mid-naughties</subtitle>
  <author>
    <name>flwyd</name>
  </author>
  <link rel="alternate" type="text/html" href="https://flwyd.dreamwidth.org/"/>
  <link rel="self" type="text/xml" href="https://flwyd.dreamwidth.org/data/atom"/>
  <updated>2020-04-30T05:38:58Z</updated>
  <dw:journal username="flwyd" type="personal"/>
  <entry>
    <id>tag:dreamwidth.org,2017-01-08:2740657:392000</id>
    <link rel="alternate" type="text/html" href="https://flwyd.dreamwidth.org/392000.html"/>
    <link rel="self" type="text/xml" href="https://flwyd.dreamwidth.org/data/atom/?itemid=392000"/>
    <title>conjoin: A Vim Plugin for Continuation Characters</title>
    <published>2020-04-30T05:29:31Z</published>
    <updated>2020-04-30T05:38:58Z</updated>
    <category term="vim"/>
    <category term="editor"/>
    <category term="programming"/>
    <category term="covid-19"/>
    <category term="coronavirus"/>
    <dw:music>KGNU - Reggae Transfusion</dw:music>
    <dw:mood>quixotic</dw:mood>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">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="https://github.com/flwyd/curse"&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'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 "the command keeps going on the next line") in the middle of the combined line.  After a bunch of Googling, I determined that there wasn'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;"lorem ipsum"&lt;/kbd&gt; rather than &lt;kbd&gt;"lorem " + "ipsum"&lt;/kbd&gt;).  This in turn provided a great excuse to geek out on programming language details on Wikipedia, &lt;a href="https://rosettacode.org/"&gt;Rosetta Code&lt;/a&gt; and &lt;a href="http://99-bottles-of-beer.net/"&gt;99-bottles-of-beer.net&lt;/a&gt;.  &lt;strong&gt;And thus was born &lt;a href="https://github.com/flwyd/vim-conjoin"&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="https://xkcd.com/1205"&gt;XKCD'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'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'll have a much better idea of what I'm doing.  And I learned more in a couple weeks about &lt;kbd&gt;vim&lt;/kbd&gt; than I've learned in most individual years in the last two and a half decades I've used the editor.  (Though it's going to take me awhile to remember to put &lt;kbd&gt;call&lt;/kbd&gt; before function invocations and I'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="https://en.wikipedia.org/wiki/INTERCAL"&gt;INTERCAL&lt;/a&gt; a famously obtuse parody language, and &lt;a href="https://en.wikipedia.org/wiki/LOLCODE"&gt;LOLCODE&lt;/a&gt;, a lolcat-inspired esoteric programming language that I wish I'd heard about in 2007 when it was announced.  (LOLCODE unfortunately seems to have been abandoned; the language author hasn't responded to a &lt;a href="https://github.com/justinmeza/lolcode-spec/issues/11"&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've got an unnecessarily polished tool while doing so.&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=flwyd&amp;ditemid=392000" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
</feed>
