index.md (10906B)
1 --- 2 title: "Vim is a cast iron skillet" 3 description: "Year-end thoughts on why I like my text editor" 4 date: 2024-12-24T07:59:00-08:00 5 draft: false 6 categories: 7 - Programming 8 - Data Science 9 - Personal 10 --- 11 12 Yesterday was dark and chilly, demanding a one-pan casserole for dinner. 13 I sauteed the filling in my skillet, and once the gravy was ready and the 14 flavors had married, I topped it with potatoes and moved the pan to a hot 15 oven to finish. 16 17 I cleaned the pan before work this morning. Hot water leftover from making 18 coffee softened the dried residue, then I put a plastic bowl-scraper to 19 task. I finally gave it a good scrub with a brush, dabbed it dry, and 20 rubbed a thin layer of vegetable oil over it. 21 22 I don't think I go as overboard as some cast iron aficionados, but I try to 23 take care of my cookware. I've only had to remove the "seasoning" (a coating 24 of polymerized oil) and re-season it once in over a decade of ownership. 25 This way it should last forever; I have a cast iron comal from the 1950s in 26 great condition. But it requires more work than is necessary. My wife will 27 have nothing to do with my pan; if she was making the same recipe she 28 would've cooked the filling in a non-stick skillet and baked everything in 29 a glass casserole dish; cleanup would have been a breeze. 30 31 Her approach isn't wrong, but it represents a different set of trade-offs. 32 As I scraped dried gravy off the sides of a pan, a mawkish simile came to 33 mind: 34 35 > This skillet is just like **Vim**. 36 37 It is meaningless to say that [Vim](https://www.vim.org/) is a text editor. 38 Most visitors to a website like this one[^website] are probably familiar 39 with Vim, know exactly what I mean by "text editor", and already have their 40 minds made up about which ones are good. Otherwise, readers might get the 41 gist of what I'm saying but miss out on some finer points. 42 43 A text editor is a computer program that edits text files. This sounds 44 straightforward, but confusingly, most "texts" edited on computers are not 45 text files and are written in "word processors"---a different kind of 46 program with different features and affordances. Some Windows users have 47 been exposed to Notepad.exe, which is _technically_ a text editor, and might 48 assume that word processors are more featureful versions of the same basic 49 thing. But because nearly all computer programs are authored through plain 50 text files, there is a profusion of text editors with powerful features to 51 make programmers' work easier. Microsoft happens to make both the most 52 popular word processor (MS Word) and the text editor most frequently used by 53 programmers (VSCode), but I don't care for either: I try to write everything 54 in Vim. 55 56 Vim was released as "Vim" in 1991, and is an extended version of vi, which 57 itself has been around since 1976. Its default interface---the one I use 58 daily---is a "text user interface" that's launched in a terminal emulator 59 (i.e., the "command line"[^command-line]). Vim has mouse support, but it's 60 superfluous because everything can be accomplished through commands typed on 61 the keyboard. Its default display is unadorned, presenting only a page of 62 the characters that you typed and a single line of status information at the 63 bottom of the screen. 64 65 Owing perhaps to its Spartan interface, Vim is popular with the sort who 66 decry software "bloat"---features that are decorative or unimportant that 67 slow computers down. Whether Vim should be considered bloated or not, it can 68 do nearly anything you could imagine doing to a text file, and has an 69 extensive plugin system that can do literally everything that a computer can 70 do, all from inside its interface. 71 72 I became a "Vim user" around the turn of the century when I was still in 73 college. But as I close out 2024, the emergent themes for my computer use in 74 the past year are a return to basics and an attempt to master my tools. For 75 example, many of my [December Adventure]({{< relref "/december-adventure/" 76 >}}) updates for this year catalog my attempts to push my [Git]({{< relref 77 "/tags/git/" >}}) skills further. And when I say that I use Vim for 78 _everything_, it's because I've been using it for editing tasks I previously 79 hadn't[^editing], so that I could become more comfortable with features I've 80 neglected. 81 82 It's common to evaluate a tool by placing it on a continuum running from 83 general purpose multitaskers (which can do many things _ok_) to 84 laser-focused unitaskers (which do a single thing well). But some tools in 85 our toolbox are pretty good at many things and are also the best at 86 a specific thing. A cast iron skillet isn't the best way to fry an egg, but 87 it _can_ fry an egg and it's the _best_ way to bake cornbread (IMHO). Vim 88 may not be the best tool for writing a film script, but it is---to pick one 89 example---the best one for interactively running regular expressions[^regex] 90 in a document. 91 92 Such tools still require trade-offs. Cast iron is heavier, more difficult to 93 clean, and heats less evenly than some cookware options. Vim has a steep 94 learning curve and resists playful exploration, which can make other complex 95 computer programs fun to practice. You don't need to be able to do 96 everything with Vim to use it---plenty of programmers who prefer other 97 editors know the basics well enough to use Vim to touch up text on 98 unfamiliar machines[^remote]---but reaching a level of proficiency where 99 editing files in Vim is as easy as using other text editors opens a pathway 100 to a more fluid way of working with text. 101 102 So what makes Vim great? I mentioned its keyboard-focused interface, but by 103 requiring that a user switch between _modes_, commands are activated with 104 minimal finger movement from the keyboard's "home row". Juggling modes is 105 cognitively taxing at first but eventually becomes second nature, unlocking 106 the benefits of keeping the most common commands directly under your 107 fingertips. Vim also achieves brevity at the expense of intelligibility. In 108 the ironically named "normal mode", for example, typing the sequence `dap` 109 will delete the current paragraph and place it on the clipboard; you could 110 then move your cursor (which is primarily accomplished with the `h`, `j`, 111 `k`, and `l` keys) and paste the paragraph elsewhere by typing `p`. Vim's 112 "insert mode" offers a more familiar interface where typing letters adds 113 them to the document; seasoned Vim users only stay in this one while 114 actively writing and quickly escape to normal mode[^esc]. 115 116 The arcane commands comprising normal mode take practice to learn, but 117 ultimately introduce little mental workload to the process of editing text; 118 once you've mastered a sequence it becomes muscle memory, relegated to 119 a different part of the brain than the one trying to implement an algorithm 120 or compose prose. Since most editing commands use the same keys that fall 121 under the fingers when inserting, large edits become lightning quick. This 122 is where I've been pushing myself; one can get pretty far with only the most 123 common commands, but the more of them one knows the faster everything 124 becomes. 125 126 Like a well-seasoned cast iron skillet, Vim becomes a tool that you can use 127 for everything once you're adapted to its quirks. I felt like I reached that 128 point when I started running a terminal emulator inside my text editor 129 (which, you may recall, is itself running in a terminal emulator) so 130 I wouldn't have to use a mouse or awkward chordal key combinations[^emacs] 131 to copy things back and forth between my editor and other programs in the 132 terminal. An ancillary benefit of doing everything in Vim is that I get the 133 same familiar behavior whether I'm using macOS (which I use for my day job), 134 Linux (which I use in my free time), and Windows (which I use under duress), 135 even though these platforms have distinct UX conventions. 136 137 Bram Moolenaar, who created Vim and lead its development since its release, 138 passed away last year. I will be forever grateful for his gift to the open 139 source ecosystem, and impressed that he used the popularity of his project 140 to [raise funds for charity work](https://www.iccf-holland.org/). 141 Development of Vim continues, and the [Neovim](https://neovim.io/) fork is 142 popular in its own right. I've been switching between the two versions for 143 the past year; I don't use many features of Neovim that aren't present in 144 Vim, but I am excited by some of the directions its developers are 145 exploring. 146 147 I love my text editor and consider it superior to the alternatives, but I'm 148 not here to evangelize Vim. Rather, I hope to encourage someone else to look 149 at the tools they use the most often---analog and digital alike---and 150 challenge themselves to achieve a higher level of mastery in their use. The 151 joy of learning for its own sake is easy to forget, and there's no better 152 place to start looking for opportunities to learn than with the things we do 153 every day. Like edit text on a computer. 154 155 [^website]: A blog mostly about data science and programming at www dot 156 first name last name dot net. 157 158 [^command-line]: People who used the earliest word processors (like my 159 parents) have experience with TUIs on single-user platforms like Amiga 160 and DOS. [A few authors](https://sfwriter.com/wordstar.htm) remain 161 committed to writing in such interfaces, for some of the same reasons 162 I like Vim. 163 164 [^editing]: E.g., writing Markdown in Vim has replaced much of my word 165 processor use, and lately I'm running an R "REPL" in a split Vim window 166 rather than launching the RStudio IDE. 167 168 [^regex]: A mere footnote can't do regular expressions justice. The short 169 version is that they comprise a specialized language unto itself for 170 defining pattern matches and replacements for text. A word processor's 171 "find and replace" function is fine for _writing_, but regular 172 expressions are crucial tools for _computing_. I would struggle to do my 173 job (analyzing data and writing code to analyze data) without them. 174 175 [^remote]: This is especially the case when connecting to a remote machine 176 over SSH. Nearly every Unix has a version of the `vi` program available, 177 and usually it's Vim. If you're on a Mac, your computer came with 178 Vim---but it's also available on computers running MS-DOS, Windows, and 179 AmigaOS. 180 181 [^esc]: Returning to normal mode is literally achieved through the "escape" 182 key (by default). Some of us "remap" the keyboard to swap the 183 functionality of the hard-to-reach _escape_ and the infrequently-used 184 _caps lock_ keys. 185 186 [^emacs]: [Emacs](https://www.gnu.org/software/emacs/) is another text 187 editor of a similar vintage as vi with its own acolytes. Instead of 188 relying so heavily on modes, it more frequently requires its users to 189 press multiple keys at once. But here I'm talking about the 190 idiosyncratic key combinations that different terminal emulators require 191 in order to copy paste into and out of them, where the familiar Control 192 plus C can't work for reasons that aren't relevant here.