conjoin: A Vim Plugin for Continuation Characters
Wednesday, April 29th, 2020 10:53 pmnoun=(apple-john baggage barnacle bladder boar-pig bugbear bum-bailey \Unfortunately, the J command in vim 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 vim setting to do so, and nobody had written a plugin for it either.
canker-blossom clack-dish clotpole coxcomb codpiece crutch cutpurse \
death-token dewberry dogfish egg-shell flap-dragon flax-wench flirt-gill \
foot-licker fustilarian giglet gudgeon gull-catcher haggard harpy hedge-pig \
hempseed horn-beast hugger-mugger jack-a-nape jolthead lewdster lout \
maggot-pie malignancy malkin malt-worm mammet manikin measle minimus minnow \
miscreant moldwarp mumble-news nut-hook pantaloon pigeon-egg pignut puttock \
pumpion rabbit-sucker rampallion ratsbane remnant rudesby ruffian scantling \
scullion scut skainsmate snipe strumpet varlot vassal waterfly whey-face \
whipster wagtail younker)
So of course I decided that extra home-bound free time meant it was time to learn how to write a vim 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 "lorem ipsum" rather than "lorem " + "ipsum"). This in turn provided a great excuse to geek out on programming language details on Wikipedia, Rosetta Code and 99-bottles-of-beer.net. And thus was born vim-conjoin, a plugin that remaps J, gJ, and :Join to handle continuation breaks and string concatenation.
This exercise was absolutely a violation of XKCD's Is It Worth the Time 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 vim users find it useful, too.
As with any personal programming project, the time wasn't entirely wasted, of course. The next time I want to write a vim plugin I'll have a much better idea of what I'm doing. And I learned more in a couple weeks about vim 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 call before function invocations and I'm forever forgetting the l: and a: prefixes on local and argument variables.) And the Wikipedia adventures led me to finally read up on INTERCAL a famously obtuse parody language, and LOLCODE, 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 2018 proposal for array (BUKKIT) syntax.) And that gave me an idea for an esoteric language of my own that I hope to work out during the remainder of quarantine time…
You do you. And make sure you've got an unnecessarily polished tool while doing so.