If you have failed to grok vim, ditch the arrow keys

As much as I am embarrassed to admit, I have been using vi/vim for the last 10 years or so (admittedly only on remote servers for editing configs for 8 of those years) and I am just now getting around to getting better at it.

In this, one recent post on Hacker News reiterated something that was the single most important step to take to improve your vim fluidity: use hjkl instead of the arrows keys.

Folks may argue that the transaction cost of getting to the arrow keys is insignificant, but it ignores that when you use the arrow keys, you essentially are moving your hand away from every important vim command. That minor increase in transaction cost by moving over to the arrow keys is multiplicative with the transaction cost of using the standard vim commands. In other words, you are far less likely to learn other vim commands when you have the friction of moving your hand back in addition to the friction of learning the command itself.

Once you have relinquished your hands to being ready to learn, you can start adding on top of that with new commands as you move around.

Keep in mind whilst using vim: it is more-or-less feature complete. If there is something that you feel you are not doing as fast as possible–you are doing it wrong. So whenever you feel the friction you felt when you used the arrow keys, look around and find that command that lubricates that action.

Ultimately, the reason that vim zealots are so frothy about their editor is that once you have the muscle memory to be completely fluid in the editing of text, you can focus on the actual task at hand (and not the tool being used). Every time you have to do that minor transaction between your hand and move it to the mouse, or feel encumbered by your editor, you are an artist concerned with the sanding of your brush handle or the easel holding your canvas. These are things incidental to the end result: the product. The focus. The very point of using a tool: to produce.

  • AK

    But as array keys are there and are clearly very easy to use why shouldn’t we use them? I mean arrow keys are sth that you can use even while editing unlike hjkl.

    I also believe that hjkl was not used for movement because it was the best option – as has been revealed it was used because it was the arrow-keys. So, while I must say that yes it actually distracts your right hand away from main keys but even if it needs to be done away with – do you(or anyone) really believe hjkl should be the answer(reason: above^) and not some other key combo like wasd or something else which is actually easier and more convenient esp for grokking? I mean we shouldn’t stick to sth better just because it has been stated better.
    If we use wasd or any other combo then comes the question of what to do with those functionalities involved with w,a,s,d – i.e. word …delete etc.?

    I face another problem and that is I am not able to touch type. I try to learn but the tutorials and tools are so bring that I give up :(

    I wish I could find a way to learn touch typing.

    • http://twitter.com/h6o6 h6o6

      One thing I should have mentioned is that using hjkl also forces you to escape editing mode often, which makes using the vim commands that much more available to you (and easier to pick up). Sometimes the arrow keys save some time by saving you the escape, but as soon as you need to do anything besides add text it becomes a detriment.

      As a recovering Unreal Tournament (GOTY) addict, wasd is definitely comfortable. If you want to go ueberdork, you can remap the vim keys. Like you said, the problem is of course that wasd are all vim commands–some of them extremely important and you sort of want ready on your home row. I suppose you might be able to use your now dead hjkl keys for some of these commands :)

      I found that instant messaging/chat is the best motivator for touch typing. The faster you can get your message out, the better! Best of luck.

      • AK

        Thanks for detailed and thoughtful response. You are right about the key-remap dilemma. BTW, I browsed some code today having disabled arrow keys and I must say I am getting a hang of hjkl :P.

        Toyed with the idea of making h-UP j-DOWN and k-LEFT l-RIGHT, instead I just made it -> “jkl;”

        And yes IM is ba ig motivation. The thing is I type quite fast(accuracy is below expectation). It’s a combination of spec-n-peck(minimal) and mostly touch, but as there’s some spec too, so it’s not touch. And even when it’s just touch – the finger mapping is far from the standard mapping and placement. Whenever I try to stick to pure touch typing the time kicks in and I immediately resort to my used to method for faster typing)in shorter run). I even tried keeping my keyboard under the table slightly inside in the dark so that I won’t see it. Didn’t work, it was stupid :P

        Guess some will-power shall help. Will see. Cheers :-)

  • Dmitriy Likhten

    Yeah, no. Dude I grok’d vim when I did di” and Ctl+k(plugin)i” <– replace motion with what is in the buffer. Once I used this like twice, I could no longer edit in other editors :)

    Oh sure you CAN do it with some unknown key combinations, but the best part of vim is you learn the editing language, the more you know the more efficient you are. But unlike every other editor, vim does not require you to know literally everything.

    • http://twitter.com/h6o6 h6o6

      Great point, you really only need to know enough to get comfortable. Not to start a flame war, but this is the reason why I could never get my head around emacs.

  • Tyler Jameson Little

    HJKL doesn’t make sense with Dvorak, but I still grok vim just fine. The things that really keep me with vim are macros, marks (and deletion/yanking with marks), (v)split, and regex search & replace.

    I have never used emacs, so I can’t comment on features there, but I haven’t used an editor that has such features baked in.