commit 24b1a93b50684dad4715a96afad10aa7b90d0e6d
parent a310a46081b87130bdeb0b8183e5a08d706c1a71
Author: Eamon Caddigan <eamon.caddigan@gmail.com>
Date: Mon, 23 Dec 2024 20:41:49 -0800
Finish a long post about why I like Vim
Diffstat:
1 file changed, 192 insertions(+), 0 deletions(-)
diff --git a/content/posts/vim/index.md b/content/posts/vim/index.md
@@ -0,0 +1,192 @@
+---
+title: "Vim is a cast iron skillet"
+description: "Year-end thoughts on why I like my text editor"
+date: 2024-12-24T07:59:00-08:00
+draft: false
+categories:
+- Programming
+- Data Science
+- Personal
+---
+
+Yesterday was dark and chilly, demanding a one-pan casserole for dinner.
+I sauteed the filling in my skillet, and once the gravy was ready and the
+flavors had married, I topped it with potatoes and moved the pan to a hot
+oven to finish.
+
+I cleaned the pan before work this morning. Hot water leftover from making
+coffee softened the dried residue, then I put a plastic bowl-scraper to
+task. I finally gave it a good scrub with a brush, dabbed it dry, and
+rubbed a thin layer of vegetable oil over it.
+
+I don't think I go as overboard as some cast iron aficionados, but I try to
+take care of my cookware. I've only had to remove the "seasoning" (a coating
+of polymerized oil) and re-season it once in over a decade of ownership.
+This way it should last forever; I have a cast iron comal from the 1950s in
+great condition. But it requires more work than is necessary. My wife will
+have nothing to do with my pan; if she was making the same recipe she
+would've cooked the filling in a non-stick skillet and baked everything in
+a glass casserole dish; cleanup would have been a breeze.
+
+Her approach isn't wrong, but it represents a different set of trade-offs.
+As I scraped dried gravy off the sides of a pan, a mawkish simile came to
+mind:
+
+> This skillet is just like **Vim**.
+
+It is meaningless to say that [Vim](https://www.vim.org/) is a text editor.
+Most visitors to a website like this one[^website] are probably familiar
+with Vim, know exactly what I mean by "text editor", and already have their
+minds made up about which ones are good. Otherwise, readers might get the
+gist of what I'm saying but miss out on some finer points.
+
+A text editor is a computer program that edits text files. This sounds
+straightforward, but confusingly, most "texts" edited on computers are not
+text files and are written in "word processors"---a different kind of
+program with different features and affordances. Some Windows users have
+been exposed to Notepad.exe, which is _technically_ a text editor, and might
+assume that word processors are more featureful versions of the same basic
+thing. But because nearly all computer programs are authored through plain
+text files, there is a profusion of text editors with powerful features to
+make programmers' work easier. Microsoft happens to make both the most
+popular word processor (MS Word) and the text editor most frequently used by
+programmers (VSCode), but I don't care for either: I try to write everything
+in Vim.
+
+Vim was released as "Vim" in 1991, and is an extended version of vi, which
+itself has been around since 1976. Its default interface---the one I use
+daily---is a "text user interface" that's launched in a terminal emulator
+(i.e., the "command line"[^command-line]). Vim has mouse support, but it's
+superfluous because everything can be accomplished through commands typed on
+the keyboard. Its default display is unadorned, presenting only a page of
+the characters that you typed and a single line of status information at the
+bottom of the screen.
+
+Owing perhaps to its Spartan interface, Vim is popular with the sort who
+decry software "bloat"---features that are decorative or unimportant that
+slow computers down. Whether Vim should be considered bloated or not, it can
+do nearly anything you could imagine doing to a text file, and has an
+extensive plugin system that can do literally everything that a computer can
+do, all from inside its interface.
+
+I became a "Vim user" around the turn of the century when I was still in
+college. But as I close out 2024, the emergent themes for my computer use in
+the past year are a return to basics and an attempt to master my tools. For
+example, many of my [December Adventure]({{< relref "/december-adventure/"
+>}}) updates for this year catalog my attempts to push my [Git]({{< relref
+"/tags/git/" >}}) skills further. And when I say that I use Vim for
+_everything_, it's because I've been using it for editing tasks I previously
+hadn't[^editing], so that I could become more comfortable with features I've
+neglected.
+
+It's common to evaluate a tool by placing it on a continuum running from
+general purpose multitaskers (which can do many things _ok_) to
+laser-focused unitaskers (which do a single thing well). But some tools in
+our toolbox are pretty good at many things and are also the best at
+a specific thing. A cast iron skillet isn't the best way to fry an egg, but
+it _can_ fry an egg and it's the _best_ way to bake cornbread (IMHO). Vim
+may not be the best tool for writing a film script, but it is---to pick one
+example---the best one for interactively running regular expressions[^regex]
+in a document.
+
+Such tools still require trade-offs. Cast iron is heavier, more difficult to
+clean, and heats less evenly than some cookware options. Vim has a steep
+learning curve and resists playful exploration, which can make other complex
+computer programs fun to practice. You don't need to be able to do
+everything with Vim to use it---plenty of programmers who prefer other
+editors know the basics well enough to use Vim to touch up text on
+unfamiliar machines[^remote]---but reaching a level of proficiency where
+editing files in Vim is as easy as using other text editors opens a pathway
+to a more fluid way of working with text.
+
+So what makes Vim great? I mentioned its keyboard-focused interface, but by
+requiring that a user switch between _modes_, commands are activated with
+minimal finger movement from the keyboard's "home row". Juggling modes is
+cognitively taxing at first but eventually becomes second nature, unlocking
+the benefits of keeping the most common commands directly under your
+fingertips. Vim also achieves brevity at the expense of intelligibility. In
+the ironically named "normal mode", for example, typing the sequence `dap`
+will delete the current paragraph and place it on the clipboard; you could
+then move your cursor (which is primarily accomplished with the `h`, `j`,
+`k`, and `l` keys) and paste the paragraph elsewhere by typing `p`. Vim's
+"insert mode" offers a more familiar interface where typing letters adds
+them to the document; seasoned Vim users only stay in this one while
+actively writing and quickly escape to normal mode[^esc].
+
+The arcane commands comprising normal mode take practice to learn, but
+ultimately introduce little mental workload to the process of editing text;
+once you've mastered a sequence it becomes muscle memory, relegated to
+a different part of the brain than the one trying to implement an algorithm
+or compose prose. Since most editing commands use the same keys that fall
+under the fingers when inserting, large edits become lightning quick. This
+is where I've been pushing myself; one can get pretty far with only the most
+common commands, but the more of them one knows the faster everything
+becomes.
+
+Like a well-seasoned cast iron skillet, Vim becomes a tool that you can use
+for everything once you're adapted to its quirks. I felt like I reached that
+point when I started running a terminal emulator inside my text editor
+(which, you may recall, is itself running in a terminal emulator) so
+I wouldn't have to use a mouse or awkward chordal key combinations[^emacs]
+to copy things back and forth between my editor and other programs in the
+terminal. An ancillary benefit of doing everything in Vim is that I get the
+same familiar behavior whether I'm using macOS (which I use for my day job),
+Linux (which I use in my free time), and Windows (which I use under duress),
+even though these platforms have distinct UX conventions.
+
+Bram Moolenaar, who created Vim and lead its development since its release,
+passed away last year. I will be forever grateful for his gift to the open
+source ecosystem, and impressed that he used the popularity of his project
+to [raise funds for charity work](https://www.iccf-holland.org/).
+Development of Vim continues, and the [Neovim](https://neovim.io/) fork is
+popular in its own right. I've been switching between the two versions for
+the past year; I don't use many features of Neovim that aren't present in
+Vim, but I am excited by some of the directions its developers are
+exploring.
+
+I love my text editor and consider it superior to the alternatives, but I'm
+not here to evangelize Vim. Rather, I hope to encourage someone else to look
+at the tools they use the most often---analog and digital alike---and
+challenge themselves to achieve a higher level of mastery in their use. The
+joy of learning for its own sake is easy to forget, and there's no better
+place to start looking for opportunities to learn than with the things we do
+every day. Like edit text on a computer.
+
+[^website]: A blog mostly about data science and programming at www dot
+ first name last name dot net.
+
+[^command-line]: People who used the earliest word processors (like my
+ parents) have experience with TUIs on single-user platforms like Amiga
+ and DOS. [A few authors](https://sfwriter.com/wordstar.htm) remain
+ committed to writing in such interfaces, for some of the same reasons
+ I like Vim.
+
+[^editing]: E.g., writing Markdown in Vim has replaced much of my word
+ processor use, and lately I'm running an R "REPL" in a split Vim window
+ rather than launching the RStudio IDE.
+
+[^regex]: A mere footnote can't do regular expressions justice. The short
+ version is that they comprise a specialized language unto itself for
+ defining pattern matches and replacements for text. A word processor's
+ "find and replace" function is fine for _writing_, but regular
+ expressions are crucial tools for _computing_. I would struggle to do my
+ job (analyzing data and writing code to analyze data) without them.
+
+[^remote]: This is especially the case when connecting to a remote machine
+ over SSH. Nearly every Unix has a version of the `vi` program available,
+ and usually it's Vim. If you're on a Mac, your computer came with
+ Vim---but it's also available on computers running MS-DOS, Windows, and
+ AmigaOS.
+
+[^esc]: Returning to normal mode is literally achieved through the "escape"
+ key (by default). Some of us "remap" the keyboard to swap the
+ functionality of the hard-to-reach _escape_ and the infrequently-used
+ _caps lock_ keys.
+
+[^emacs]: [Emacs](https://www.gnu.org/software/emacs/) is another text
+ editor of a similar vintage as vi with its own acolytes. Instead of
+ relying so heavily on modes, it more frequently requires its users to
+ press multiple keys at once. But here I'm talking about the
+ idiosyncratic key combinations that different terminal emulators require
+ in order to copy paste into and out of them, where the familiar Control
+ plus C can't work for reasons that aren't relevant here.