The experience of learning vim commands

There seem to be two different compartments in my brain for clusters of vim commands. One is verbal. I learned ddp to reverse two lines and xp to reverse two characters. When I did so I learned them first as “words”, and that’s how they remain in my head. I can access them fast as words, almost by reflex.

The other compartment is accretionary. I never thought of ggVG (for selecting the whole contents of a file) as a command cluster until I saw it in print, but when I did I recognized it at once as something I type all the time.

It seems most effective to let my highly verbal tendencies consolidate what I have gradually learned through accretion.

Curious vim behavior: treats date range as subtraction

I have the phrase “3-4 years” in a vim document and want to change it into “4-5 years”.

Cursor over “3″, C-a increments it to “4″. Good.

Cursor over the “4″ after the hyphen, C-a surprisingly decrements it to “3″. Repeating the action eventually produces “40 years” (hyphen deleted), after which C-a increments properly to “41 years”, etc.

Curious. I suppose vim is treating “4-4″ as subtraction rather than a date range. “4-3″ is indeed one more than “4-4″.

I tested the idea by replacing my all-purpose ASCII hyphen with an en-dash, – (–). In that case, C-a increments 4–4 to 4–5 as expected.

That doesn’t explain why “4-1″ becomes “40″ when the “1″ is decremented, though.


Update, 20120404: It has been pointed out to me that vim must be looking no further to the left than the hyphen, treating “4″ and “-3″ as separate numbers. After “-1″ has been incremented to “0″, it is seen together with “4″ as part of the number “40″, which is then incremented to “41″.

Finally making progress with Vim

Now that the semester is over, I am finally in the mood to risk using the text editor Vim for various tasks that are important to me, and so to have a chance to learn the thing for real.

Vim enthusiasts often mention the lack of hand movement as one of the attractions of this tool. I am not attracted by that, though. I prefer a certain amount of bodily entropy when studying, and the arm movements of typing are part of that. And I value the kind of memory that comes from involving my body in thinking. That is why I use standing desks (various home-made ones — I’m unwilling to pay the exorbitant prices demanded in the marketplace). That is why I still use paper books, whose physical shape serves as a guide to my recollection of what I’ve read. The minimal hand- and arm-movements needed for Vim are helpful to touch-typing, but I don’t place great store by them in themselves.

What I am really enjoying about Vim today is the need to think, even to calculate a little before doing anything other than actually typing text. It reminds me of learning to use a scythe when I was about 14. Naturally, my inclination was just to slash at the grass. But an adult watching me, one Pierce Skinner, came over and suggested that I pause for half a second before each swing of the scythe, to consider what I was about to do. My scything improved enormously and the act of fore-thinking felt very good. I am experiencing something similar right now with Vim and enjoying it.


I see Pierce Skinner is now a practicing clinical psychologist in New Jersey.

An opinion on vi configuration

What I especially liked about vi was precisely that I didn’t have to have all these nifty customizations to make it really usable. What really distinguished vi from emacs in my mind was that it was just there on any system I sat down at–tremendously portable. I didn’t have to copy my emacs profile around to sit down and do useful work on someone else’s machine.

Tim O’Reilly, Response to “Editor: vi or emacs?” in column “Ask Tim” for June, 1999. Accessed at https://oreilly.com/pub/a/oreilly/ask_tim/1999/unix_editor.html, 20111111.

The virtue of Vim (or: why I do not remap copy and paste)

This is a meditation on making my peace with Vim, the present instantiation of vi, one of the old text editors from the days of the “editor wars” before Bill Gates and Steve Jobs and their wares were fixtures in the media and our households.

In the editor wars, vi was the great rival of Emacs — this relationship has been described with precision and acerbity elsewhere, but they and their adherents were once the Punch and Judy of programmers’ intellectual world. They were seen as tokens of competing outlooks and much was made of the rivalry. When I got back into programming, I knew I would have to revive my long-deferred relationship with them. I had already found vi to suit my temperament more happily, but its learning curve is steeper so I took up Emacs first.

The two striking things about Emacs were its great power and the unfamiliar way that familiar tasks were named and conceived of. Its power is the reason to use it; the vocabulary and ideas are the price of that power. For instance, copying and pasting text are not part of Emacs — they come from the Jobs/Gates world. In Emacs there is no “clipboard” but there is a “kill-ring”, where pieces of text go when when you “kill” them with ^-k. The kill-ring is a stack structure of what we would now call clipboards, where you can find different things you have killed, if you have saved the with “kill-ring-save” (meta-key plus w). If you want to use something in the kill-ring, you “yank-pop” it back with ^-y.

I wrote this about a year ago, when I was struggling to adapt to Emacs:

Don’t think copy; think kill-ring-save;

don’t think paste; think yank.

Strange new terms are things to save;

let your mind be their bank.

I got reasonably comfortable with Emacs. It is a work of abiding quality, though as I had anticipated, not entirely perfect for me. Now I am ready to deal with Vim.

A friend recently wrote to say that he had become addicted to Vim and, despite the burden of many grave professional obligations, has found himself spending dozens of hours adjusting the settings it to suit himself. The first thing he did was remap the equivalents of copy and paste to the familiar key-commands ^-c and ^-v, and at some point after that he awoke to find himself tumbling down a steep passageway of editor configuration without end.

I told him not to feel guilty, because there are just two kinds of people: those who live on friendly terms with tools and those who don’t. We have no choice as to which kind we are. Tool-people need to spend time mastering and adjusting their tools. It is an act of self-fulfillment and neither to be rushed nor disparaged.

I did not tell him that for myself, copy/paste are among the very last things I would change.

The familiar Jobs/Gates conception of word-processing, and therefore its characteristic terminology, and therefore also its system of key commands, represents a model of thinking to which I would like to have alternatives. That was one of the big appeals about Emacs, frankly — and about Awk and TeX and Vim, all survivors from decades ago. These things, coelacanths in the ocean of modern computing, seem to me to possess a goodness of their own just because they represent a competing vision of how to work and how to use basic tools.

This, more than even Vim and Emacs in particular, is what attracts me about old utilities that have survived into the new dispensation. Using them well means training my mind to unfamiliar processes and conceptions, and that gives me a feeling of great well-being. The hunt is not about the fox.

The EMACS meta key and the standing desk

The EMACS meta key is normally mapped by default to escape. I am too stubborn to remap escape to another key, such as caps-lock, even for use within EMACS alone.

But I find myself no longer raising my left elbow and shoulder so as to hit escape with my pinky — I have begun using the middle finger of my left hand, and that seems satisfactory.

One of the advantages of the vi editor is said to be that hand movement is minimized. But I am not so sure I like that — being perfectly immobile except for my mind and my fingertips generally brings me stress, and moving around relieves it. That is also why I use a standing desk: if my whole body can fidget a little, my mind fidgets much less. And I always find that body movement aids memory and visualization.