Alternative past: Redefining the text editor
OK this is kind of weird. I was giving a presentation once where I was going to live-code Minesweeper in Clojurescript.
I wanted to avoid the situation where the audience doesn’t quite know where the live-coder started from, i.e. how much of what they’re doing is dependent upon the development environment, so to create an experience where it would feel like we were all on the same page, I purposely showed up without a computer so that I would be forced to do it truly from scratch on someone else’s machine.
When it came time to write the first text file, I knew everyone would be thinking, “What text editor are they going to use?” Vi? Emacs? Or a web browser in disguise?
So I decided I was going to disappoint everyone and not use any. I opened up the terminal and typed:
cat > core.cljs
I wrote my initial code, hit Ctrl+D and enter. (It was a bit confusing because the person had bound their
Fn key to
Ctrl and vice-versa, but I recovered quickly).
The cool thing about doing it like this is that everyone could still see all of the commands in the terminal above where I was writing the file. No clearing of the screen, no disrupting the flow of commands. Often when I’m doing a demo, or even just following a tutorial, say I forget to open a separate terminal to fire up my text editor (or can’t because it’s just a TTY, or there’s limited screen space), I experience a tinge of anxiety (or a lot) because my ADHD brain loses the context of what I was doing in the terminal. Then I cannot refer back to my command history until I then exit the editor, at which point I can no longer see the text file! Oh, the agony!
The problem is, you can only do so much with
cat. Not only is there no multiline editing, you can’t even backspace! So it’s really only practical for quick one-off files. what I want is a more fully-featured, multiline ed.
vi editor was in fact originally built as the visual mode for
ex, which was from the lineage (no pun intended) of line-based editors like
ed, and obviously this solved a major pain point and drastically increased productivity. But what if through this transition we actually lost something? I believe that something is mental continuity due to the screen-clearing. Practically speaking, this is a necessary consequence of needing to assess the dimensions of the terminal in order to calculate the rendering positions, and provide a full-screen visual experience akin to a nice, blank slate to begin one’s work.
But what if we had ameliorated that pain-point another way, and instead increased productivity by creating a more polished line-editing experience? I have often toyed with the idea of building a text editor that just sits there in your terminal and completely stays out of your way.
The closest thing I know of to this is a Clojure REPL called Rebel Readline by Bruce Hauman. I’ve taken it as a source of inspiration for how to practically build it and what it would look and feel like. It’s actually a really nice multiline experience with syntax highlighting, autocompletion, variable lookup, etc. All that is really missing is the ability to save files. And it’s a Clojure REPL, not a text editor.
BTowersCoding/med: Multiline text editor (github.com)