Vi, movement commands, efficiency, and me

December 14, 2016

In the Vi(m) community, it's an article of received and revered wisdom that you should use vi's powerful collection of movement commands as efficiently as possible, by which people mean the shortest command sequence that will do the job. I have seen more than one person write that you should (clearly) not repeat a command; instead of typing something like 'kkkk', you should clearly use '4k', and so on. Leaning on keyboard autorepeat? You're doing something terribly wrong.

I regret to tell any such people in my audience that I sin here. Repeatedly. A lot. It's generally not because I don't know about the movement commands, especially the basic ones; while my knowledge of Vi(m)'s many commands is somewhat weak and I periodically discover important new things (or at least get around to reading about them), I do know about basics like hjkl, w, and so on. No, the reason I repeat things is much simpler than that; not repeating things takes more work.

Sure, efficient commands take less typing. But at least for me they take more effort (and perhaps more time). With repeated commands I can simply lean on things until I get where I want to go; with counted commands I have to count how many whatevers I want (or see-saw back and forth), and with other efficient movement commands I have to pause to work out how to target my target (by search? by a specific character? by end or start of some thing? etc).

(With word movement specifically, part of this is that what vim considers a word versus a word boundary is not always how I think when I'm writing something; for example, 'file.ext' is three words to vim. But even beyond that, when I'm deleting or changing a phrase I don't want to pause to count how many words are in it (and I would have to count).)

Perhaps if I spent (much) more time in Vim and took various measures to attempt to build up my skills at this sort of vim golf, I would reach the point where I too was a vim command minimalist. But that doesn't seem likely to happen any time soon, so for now I'm going to keep repeating my movement commands no matter what people may think of it.

(I need to learn vim more in general (cf), but this goes in fits and starts, depending on my ability to summon enthusiasm for reading documentation, and not all of what I read sticks with me. It's the same with GNU Emacs, and for that matter the only reason I know almost all of sam is that it's quite small. And I've probably forgotten bits of sam, too.)

PS: I think that right now it would take me longer to work out the relatively minimal movement commands and type them than it takes me to brute-force repeat things, but I'm not sure and I have enough exposure to HCI to be reflexively suspicious about anything that's not backed by actual measurements. Us humans are quite good at fooling ourselves about how long things take, among other things.

PPS: This doesn't mean that I never use relatively efficient movement commands in vi, because I'm lazy. If I see an obvious quick movement, I'll use it instead of leaning on basic movement keys. Sometimes this works out, and sometimes it turns out that my clever idea to eg search backwards for some word is temporarily stymied because I used the word a second time somewhere else in the paragraph and didn't notice.

Written on 14 December 2016.
« Some of my views on Naftali Harris's 'Python 2.8'
Understanding the Let's Encrypt authorization process »

Page tools: View Source, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Wed Dec 14 01:24:50 2016
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.