Editors, tools, muscle memory

As it turns out, my muscle memory is a lot more malleable than I realised. This might be somewhat stereotypical for someone with my interests and occupation, but it took me several years of using different editors to really discover this, and it’s occasionally interesting to look back and reflect on how my choices in tooling have changed over time.

In the beginning…

…there was GNU Emacs. Well, for me, at least.

A long time ago I decided (naively) that I should get onto the whole Emacs versus Vim bandwagon, form some strong opinions and deliver hot takes. With the benefit of hindsight, I don’t generally advise this kind of approach, though surveying the tools available to you isn’t a bad thing.

I tried both Vim and Emacs, and wound up liking Emacs more. And thus I used Emacs for all my editing needs. I think I even briefly used EXWM at one point, though not for terribly long. Curiously though, I never really used Emacs for much else apart from editing text thereafter.

Then, a few years ago during a slow summer, out of boredom I decided to brush up my Vim skills, reasoning that learning something new would probably be beneficial in some way. As a result, I wound up “bilingual” in Emacs and Vim, in that I was about equally comfortable in either editor, which was an odd but useful position to be in.

I then wound up doing a sysadmin job for a summer – for a number of reasons (some historical, some practical), you’re much likelier to find Vim (or a Vi-like editor) on some random customer’s server than a usable Emacs-like editor. (The existence of GNU Nano complicates this picture slightly, but I’ll gloss over this for now, especially as Vim was what the company installed by default when provisioning new machines anyway.) Generally speaking, the ability to use Vim reasonably effectively is more or less a required skill for old-school hands-on systems administration.

That being said, pick the right tool for the job. At this job there was a small but rather useful (and moderately load bearing) Haskell program which had been around for a while, and accumulated a small collection of feature requests which nobody else had got round to doing anything about. When it gets out that you know some Haskell (more than most of the rest of the people around), and you then get assigned all of these open tickets, it’s best to use the editor for which you’ve already got a nice Haskell development configuration.

On the topic of choosing appropriate tools, I did get into the habit of selecting different editors for different things. I primarily used QEmacs for day-to-day casual text editing, however I would switch to Vim for performing highly repetitive editing tasks or block text modification. I also kept GNU Emacs around for more serious software development tasks, especially ones which required working on multiple files at once.

Emacs’s daemon mode is one feature which I find particularly useful. I’ve spent a lot of time in the past using a dual-monitor workstation while writing code, and it was useful to be able to have (different sections of) a single file visible on more than one monitor at once without having to perform weird stretching of windows across monitors. It’s also convenient for editing remotely – I can start editing a file while physically present at a workstation, and later on move to a different machine and remotely log into the original workstation, if only to save my buffer states to disk and cleanly terminate the Emacs instance.

Enter Kakoune

Some time last year, I was introduced to Kakoune by some friends. I eventually decided to give it a shot to see what it was like.

Spoiler: At the time of writing, I really like Kakoune.

Kakoune has similar client/server functionality to GNU Emacs, which fills that niche, and the keybindings are sufficiently close to Vim’s keybindings that it’s not too painful to quickly context-switch from one editor to the other. Kakoune purposefully does not do any window management of its own, instead relying on other programs such as an X11 window manager or tmux to do that instead. That prompted me to write a little wrapper program around Kakoune and tmux to compose them to provide similar session attach/detach and terminal window management functionality to what one gets from emacsclient.

Then earlier this year I had a conversation with some friends about keyboards. I was up to this point sceptical of the usability of timing-sensitive keybindings, that is ones where a short press of a key delivers one key sequence, and a long press delivers another. However, the outcome of this conversation was me remapping my laptop’s keyboard and installing xcape so that tapping the caps lock key delivers escape, and pressing and holding caps lock delivers control. This works really well with Kakoune, doubly so when combined with a plugin to provide Emacs/Readline keybindings in insert mode (which I’m still used to using in my shell interpreter).

Also, Kakoune’s multiple selections have impressed me a lot.

Step forwards, step backwards

I recently needed to go back to some Idris code which I hadn’t looked at in a while in order to do a refactoring pass (spoiler: it’s my website’s front page). One thing which Emacs has and which Kakoune does not is a plugin for interactively editing Idris code. (As an aside, such a plugin also exists for Vim, but I had Emacs already configured for this, while I haven’t ever used Vim plugins before.)

So I opened up Emacs in order to work on this Idris code, and to my surprise, Emacs was now very difficult to use at all, let alone effectively. In particular, changing where the control key is on the keyboard (with which Emacs users are otherwise very fond) was really confusing when trying to use Emacs. I wound up editing the code in Kakoune (using its Haskell highlighter in lieu of any bundled Idris highligher in Kakoune), and then switching to Emacs only for interactive syntax and type checking.

It was overall a slightly unsettling experience.

Final thoughts

The gap between the last time I was comfortable using Emacs and now is about four months, as far as I can tell from my IRC and git logs. I doesn’t feel like that long a span of time, and I’m quite surprised with how quickly my muscle memory (and more broadly, habits) has changed. I think it’s also interesting to reflect on how my choice of tools has affected me in return. Either way, I think part of my comfort with Kakoune is due to how quickly my muscle memory for Vim adapted to how Kakoune works.

Kakoune-like input layer to Emacs in the spirit of evil-mode, anyone?