131

Longtime vim users, do you keep your fingers onjkl; or hjkl in normal mode?

Standard touch typing teaches us the home position for the right hand has the index finger on the j key, so your fingers are on jkl;.

But standard vim motion keys are hjkl.

I'm getting back into vim after 10+ years (omg, I got old when I wasn't paying attention) and find myself gravitating towards hjkl ... but that makes it harder to type upper-right letters, braces, etc. I'd like to train myself to use the most efficient/pragmatic method now instead of having to re-train later.

Longtime, hardcore vim users, what's the best practice?


Note:

  1. Bigger overlap with How do touch typists navigate in vi?
  2. I think this passes the "subjective" test because it's about deliberately cultivating an unconscious best-practice and not simply about people's preference
Community
  • 1
  • 1
Sukotto
  • 2,472
  • 6
  • 26
  • 31
  • 44
    How is this _not a real question_? Hes asking where you should keep your fingers. Thats perfectly answerable. – alternative Jul 14 '11 at 20:55
  • The "best practice" is subjective in this case. People are different and will put their hands where it is comfortable for them. – Randy Morris Jul 14 '11 at 21:34
  • 1
    I'm starting and I have this same problem, jklç (pt keyboard) is better for best practice typing on a computer keyboard. It feels natural. I don't want vim making me unlearn the right way of typing I spent so much learning and practicing. – ancm Mar 12 '17 at 18:08
  • 2
    @RandyMorris Certainly people are different, and they should do whatever works best for them, however that doesn't mean that certain practices are better in most situations, the home keys for general touch typing come to mind. So I don't buy the argument that this can't be answered because its subjective, and if that is indeed the case that should be the answer with information to demonstrate why there isn't a clear best practice. – jonvw Mar 23 '20 at 19:09

5 Answers5

141

I think that jkl; is actually the more appropriate usage for vi. For one, h and l really don't matter that much. w, e, and b are significantly more useful for horizontal navigation. As a bonus, ; is easy to get at if the language requires it. Having a weaker finger on k hurts, and you don't need your strongest finger on the h, when it should be on the j which is probably the most used of the four.

alternative
  • 12,703
  • 5
  • 41
  • 41
19

Intro

Neither of the previous 2 solutions was 100% satisfactory. I propose a 3rd way, one that combines the best of both worlds

My Recomendation: "down-up-left-right"

Keep up/down where they are, then make 3rd & 4th fingers left & right

Then, to avoid overwriting base Vim features: Toss whatever used to be on ; to the now-empty h button

As a cute bonus, the "l" key now stands for "left" ;)

noremap l h
noremap ; l
noremap h ;



The previous "runners-up", who both use "left-down-up-right" layout:

Choice 1: "hjkl"

@alternative's recommendation. Keybinds stay default (hjkl), right hand stays on home row (jkl;)

  • pros:
    • j (down) and k (up) stay on your primary 2 fingers, where they deserve
  • cons:
    • You have to reach over for h (left). Even if this isn't as used as w,e,b, it's still a bloody arrow button and it would be nice to have on home row
    • Basically: All 4 fingers aren't naturally resting on arrow buttons. This confuses my hand


Choice 2: "jkl;"

Slide those 4 binds over 1 so they sit on the home row:

noremap ; l
noremap l k
noremap k j
noremap j h

  • pros:
    • No finger confusion; all the arrows are under the fingers naturally
  • cons:
    • As @alternative said, up/down being on the 2nd and 3rd finger is very "non-optimal"
    • Similarly, the strongest finger being on left is also a waste
Community
  • 1
  • 1
Bukov
  • 650
  • 8
  • 19
  • 1
    Thanks. As for your recommendation, the only thing that doesn't work so far is switching between splits with `Ctrl + W + `. – Rafał Cieślak Apr 07 '14 at 10:13
  • I'd like to add that I also accepted your recommended keymapping I use a split keyboard, where instead of dedicated arrows, arrows mimic vim (now the new!) with a modifier key pressed. A looked over added bonus of your recommendation - which I discovered by accidnt because I always have used arrow keys for it - that `less` up-down mapping is also `j` and `k`! – Krisztián Szegi Nov 08 '22 at 18:04
14

I keep my hands on the home row, in the normal touch-typist manner. Rarely do I use the h key for movement, as moving one space to the left is not usually an efficient way to move (and does not really fit the essence of Vim).

Jason Down
  • 21,731
  • 12
  • 83
  • 117
10

I understand, that hjkl is used for historic reasons (i.e. Here is why vim uses the hjkl keys as arrow keys) and it is not based on any ergonomic rationale.

I personally prefer to follow the approach recommended by i3 window manager which as explained in the FAQ on Why does the default config use jkl; instead of hjkl? is an ergonomic choice.

i3 uses jkl; because these keys make up the "home row" underneath your right hand when touch typing.

Check this on vim remapping the hjkl to jkl;

Community
  • 1
  • 1
mloskot
  • 37,086
  • 11
  • 109
  • 136
5

While I understand Vim's philosophy of having all the movement available in the home row, I found hjkl to be counter intuitive. A much more saner map I thought would be a wasd-like setup with ijkl

    nnoremap j h
    nnoremap k j
    nnoremap i k

I found this to be very easy to navigate with very natrually.

j:left
i:up
k:down
l:right

For toggling in/out of insert/normal mode, I personally use Alt-e since I almost always use Gvim and not have to worry that some terminals have issues with Alt.

    nnoremap <A-e> i
    inoremap <A-e> <esc>l
vexe
  • 5,433
  • 12
  • 52
  • 81