VIM hjkl navigation keys, aganist existing muscle memory of arrow keys

2.1k views Asked by At

I recently migrated to Vim. But I am having diffuculty making use of "hjkl" keys for navigating because of my existing muscle memory of arrow keys.

1. Is there a way to effectively use other keys like "ijkl" ( near to Arrow key layout ) without causing much conflict to other functionality in VIM , For ex: http://vim.wikia.com/wiki/Use_ijkl_to_move_the_cursor_and_h_to_insert and http://ergoemacs.org/misc/on_vi_keybinding.html

2. Is it worth the efforts to retrain the muscle memory with "hjkl" ? But the problem is, I have to use arrow keys again with Web-Browser, Outlook, and word processors ( So,the shift is causing the conflict) .

Can you suggest ( More interested to know about #2) , How did you deal with this ?

2

There are 2 answers

1
Micah Elliott On

It's a good idea to train your hand for hjkl. You could try playing rogue for a while on a daily basis until it's comfortable. It comes pretty quick.

Arrows are awful for taking your hand so far out of position. Even <Enter> is too far. I usually get away with Ctrl-J instead (a comfortable Ctrl is really important too!).

Using custom overrides for hjkl will only "help" your vim, but not other vim-like tools. In vim, remapping i will cause other issues, like what to use instead of i/I, which are very common. And you might not want to take over ; for this since right-pinky is prime real estate which I (and I think many others) map to the very frequent : (at the OS level so as not to ever be confused).

Learning hjkl will also help when you're in other places: You probably want to start using vi-mode in bash (or hopefully zsh). Gmail/mutt will be more natural. REPLs with readline support also support vi-mode. Maybe you'll do less word processing if you can replace it with text editing in vim.

Sometimes it's useful to remap things, but it's rare and often to more obscure keys/sequences. It can cause problems when you work in multiple environments, and can make sharing/pairing difficult. It can break macros and other mappings, and make recipes and articles harder to interpret. Try learning the vim-native ways first, and then deviate with experience when really justified.

5
romainl On

I have been using Vim for five years (after many more years of computer usage) without ever doing any conscious or unconscious effort to use HJKL for navigation.

  • I don't touch-type so the "home row" means nothing to me.
  • Even if I did, jkl; would make a lot more sense anyway.
  • I hit the arrows with the side of my right hand so there's not much cost in "reaching for the arrows" for me.
  • hjkl are just as bad as the arrows because both only move character-by-character and line-by-line unless you use modifiers (numbers for hjkl and Ctrl/Shift/Alt/Cmd for the arrows). Vim has vastly better means of transportation than either hjkl or the arrows and that's what you should spend time learning:

    wW          jump to next word/WORD
    bB          jump to beginning of word/WORD
    eE          jump to end of word/WORD
    fx          jump to next x on the line
    tx          jump to character just before next x on the line
    Fx          jump to previous x on the line
    Tx          jump to character just before previous x on the line
    /foo<CR>    jump to next foo
    ?bar<CR>    jump to previous bar
    }           jump to next blank line
    

and so on… :h navigation will blow your mind.

So my answer is: don't bother forcing yourself to use hjkl, it's not worth the hassle.