tadhg.com
tadhg.com
 

Vim: the Killer Instinct of Text Editors

23:45 Thu 04 Mar 2010. Updated: 00:47 05 Mar 2010
[, , , , ]

I played Killer Instinct a lot in the mid-90s. It didn’t have the multiplayer depth of Super Street Fighter II Turbo, but I wasn’t playing it multiplayer much—rather, I was trying to get the longest combination move I could.

But what does this have to do with text editing?

I’ve always been inclined to try to get things done quickly with computers. I generally try to find the keyboard shortcuts for operations and commit them to memory fast, feeling that doing otherwise will lead to a lot of wasted time, and also to there being too long a gap between my intention and its execution on the screen. This was probably most advanced (prior to now) when I was doing a lot of Photoshop work in the late 90s.

That work came after I’d been heavily into fighting games for a while. While not all fighting games do this, most of them have a concept of a “combination”, a series of moves that, if executed properly, all hit an opponent who gets hit by the first one—that is, once the combo starts, the opponent cannot block in between hits. This makes mistakes significantly more lethal, as if you leave an opening for someone who can reliably hit a powerful combo, you take a lot more damage than against someone who just knows how to hit you once or twice. Note: each “move” (sequence of inputs) can result in more than one hit; for example in Super Street Fighter II Turbo Ken’s heavy Dragon Punch (down, down/forward, forward, heavy punch) registers as three hits rather than one.

I got into playing Ken in Super Street Fighter II Turbo and focused on trying to finish opponents off with a five- or six-hit super combo (I think you could chain his super onto a heavy punch from the air), and this focus on combos made me a perfect customer for Killer Instinct, which took the combo approach and brought it to fairly ridiculous levels. Ken’s six-hit super combo in SSF2T (if you could indeed chain it onto a heavy punch) required this sequence:

Up/Forward, Heavy Punch, Forward, Down, Down/Forward, Forward, Down, Down/Forward, Heavy Punch

That’s reasonably manageable. It requires quickness and precision, because you have to do it pretty fast and the sequence has to be correct, but it’s not all that hard to remember or to execute. Killer Instinct, however, required somewhat more; here’s what Orchid’s 46-hit Ultra Combo was (if I recall correctly):

Back, Light Punch, Forward, Heavy Kick,
Back, Light Punch, Forward, Heavy Kick,
Light Punch, Back, Medium Kick,
Light Punch, Forward, Heavy Kick,
Back, Light Punch, Forward, Heavy Kick,
Forward, Medium Punch,
<pause>
Down, Down/Forward, Forward, Light Punch.

I broke it onto multiple lines for clarity. That wasn’t the toughest or longest combo in the game, and there are certainly tougher ones in other games, but I think that Killer Instinct represented a clear next step from earlier fighting games in terms of combo intricacy. There’s a YouTube clip of what that input sequence results in (for reasons I won’t go into the combo in the clip results in 48 hits instead of 45, but it’s almost the same series of inputs.)

Part of the difficulty was execution and timing, but part of the difficulty was also remembering the right sequences and when they could be applied; in it and other fighting games just going for the big combo isn’t the right move every time, and you need to tailor your choice to the situation.

In that way, there’s a similarity to keyboard shortcuts in applications. This is much more significant on Windows and certain Unix systems than on OS X, because OS X doesn’t use the Alt key (plus whatever letter) to open application menus. This is one of the things I always hated about Mac OSes, and have only gotten past by figuring out other ways to get my applications to do what I want. However, where the Alt key approach is available, invoking certain actions becomes a matter of chaining together keystrokes—for example, in some versions of OpenOffice Writer, you get to the Zoom dialog by hitting Alt-V followed by Z. In applications where there are a ton of actions, remembering a sequence of Alt keypresses was often easier than memorizing the chord for each, assuming there was a chord for that particular option.

Certain other basic text handling shortcuts are similar, like (your UI’s meta key)+Left Arrow to jump back a word, or Shift+(your UI’s meta key)+Left Arrow to select all the text going back a word, but they reach a limit fairly quickly.

Your quick text manipulation capabilities rapidly reach a limit, that is, unless you’re using an editor that’s basically designed to work without a mouse, and to make text manipulation as easy as possible. Like Vim.

Vim is a modal editor, and so the typical text editor (or word processor) approach where you immediately see on the screen what you type is just one mode (Insert mode). Vim basically assumes that Insert mode is pretty easy, and that real power comes from manipulating the text in ways other than typing what you want. Where other text editors effectively give you access to non-insert modes by letting you use the mouse, or use chording keyboard shortcuts (which are often somewhat awkward), Vim gives you the whole keyboard.

h is move left, l is move right, j is move down, k is move up. So far so simple, and not better than the arrow keys. But… numbers in front of those commands make them repeat. 30k jumps up 30 lines.

What if you want to delete? d(something) deletes something. So dl would delete the next character right.

20dl deletes 20 characters right. Vim recognizes words in the sense of strings of letters broken by non-letter characters so instead of moving one cursor line or column you can move in chunks of words.

Delete the rest of the word your cursor is over? dw. Delete the next 20 words? 20dw.

The same kind of thing applies to copying and changing text; when I decided halfway through this paragraph that I wanted to remove the commas I had inserted between the keystrokes that made up the Vim combos, I hit jj to exit Insert mode, ^ to go back to the start of the line, f, to reach the first comma, x to delete it; then I realized that the rest of my line only had comma in the commands, so I hit vg$ to select to the end of the visual line, then :s/,//<Return> to replace the commas with nothing, and then A to return to Insert mode at the end of the line.

You might be looking at that wondering how the hell it’s useful to have to wade through all that crap in order to do something you could do with the mouse and a bunch of moves, clicks, and the delete key. The answer is that it’s faster this way once you know how, and that further the basic moves Vim gives you turn into combos quite naturally, and then longer ones as you learn to extend their power.

Unlike fighting game combos, in Vim you generally have as much time as you want to enter the next key for each one, but for me a lot of it is about speed. The narrower the gap between when I think of an edit and when I’ve made that edit, the better the chance of my keeping my train of thought, and more generally the more edits I can get done in a shorter time.

On top of this, I get a kick out of figuring out how to chain together the combo and execute it properly, just like I got a kick out of stringing together forty-plus hits with Orchid. It’s not exactly the same kick, but there’s enough similarity there that my brain responds positively. At the same time, it’s reinforcing the learning of skills that are extremely useful for many important tasks (such as writing and coding), and so doesn’t have the potentially unhealthy drawbacks I discussed when going over my history with Super Street Fighter II Turbo.

And I get most of those kicks without having to move my hands from the home row.

So is Vim an editor for people who like video games with ridiculously intricate move sequences? Not exclusively, no. I’m sure I’m part of a rather small minority, and Vim can be compared many other things, including Nethack, a game that’s rather far away from Killer Instinct.

If you work with text quite a lot, learning and using Vim is probably going to speed you up as much as learning to touch type (and possibly more). It’s definitely frustrating at first, but if you’re willing to put in the time to get the basics, it will prove a good investment later. I’m certainly very happy I’m using it, and (despite still having a lot of respect for jEdit) wish that I’d moved over to it earlier.

My adoption of it was slowed by my having become habituated to buffer management in other editors, and not so much by the concept of modes, or dealing with remembering what the keys did, so I don’t think my path for learning it was all that typical. Hence I don’t know if any of the tutorials I’m about to link to are any good, but hopefully you can find one that works for you.

The absolute first things you should know: i to enter Insert mode so that you can write the text you want to write; <Esc> to get back to normal mode so you can edit, and move around, and start learning what the other keys do.

In Normal mode (i.e. after you’ve hit <Esc>, or when you first open Vim), :help<Return> will give you help, and :vimtutor<Return> will start a tutorial.

Vim is free software and is available for more or less every platform.

Some tutorials:

2 Responses to “Vim: the Killer Instinct of Text Editors”

  1. Barak Says:

    I’m glad you’ve come to the correct editor :) I seem to recall evangelizing Vim previously…

    Now when you start writing vimscripts and personal colorschemes and so on, post more, because the best tools come of necessity.

    Now get into plugins; I personally use TabBar, vcscommand and all the cscope bindings day-to-day.

    Welcome to the brotherhood.
    :wq

  2. Tadhg Says:

    Barak: “start writing plugins”? I mentioned that my adoption path was different from most people’s—more or less the first thing I did was write plugins. I wrote plugins before ever using Vim as a daily editor; the same goes for color schemes and other personalization stuff. I also wrote my own syntax file for reStructuredText, because I didn’t like the one that was out there.

    I use BufExplorer most, and a bunch of Python editing aids, probably followed by sessionman.vim, and then NERDTree and snipMate to a significantly lesser extent. Oh, and Bclose.

    I kind of always knew I’d move to Vim eventually. I just needed the time to devote to switching over, really. (Although if I’d moved before I wrote all my jEdit macros, the switch to Vim would have been significantly easier…).

Leave a Reply