I type with a non-QWERTY keyboard layout. Many of the keys Vim uses are now on the home row, but some key bindings just don't work, the most obvious one being the hjkl keys.

How and where can I change these key bindings to work better with my keyboard layout?

2 Answers 2

:help langmap

You can remap keys in command mode but leave them intact for typing. This means you can use the intent of hjkl - adjacent homerow keys for scrolling - by pressing the positional equivalents on your keyboard. Suppose your layout is Dvorak, then those same keys are dhtn. We need to map all four, even h:

:set langmap=dh,hj,tk,nl

You can now navigate using dhtn. This won't affect :commands like this and won't change insert mode (i.e. pressing t will give you a 't').

You'll need to map other keys too for normal mode - for instance, the delete action would normally be d but that's now a navigation key. j, k or l might work since they're no longer navigation keys.

  • 1
    To be fair, Dvorak uses the keys dhtn, not htns, in the place where Qwerty uses hjkl.
    – Anthony
    Feb 21, 2015 at 17:26
  • Thanks @Anthony, I've updated the langmap command to match.
    – David Lord
    Apr 29, 2021 at 3:42

You can remap keys in vim. nnoremap [ h remaps [ to h, so you can use [ in place of h, you could remap h to what [ originally did for it to be complete. You'd have to do this for all keys though and there are different modes to consider, so I guess it would be a bit of a pain.

  • Since I'll be using vim for at least the next 10 years I'd think it worth the investment. Where do I use this for the change to be reasonably permanent?
    – Earthliŋ
    Feb 4, 2015 at 1:49
  • 1
    you should put this in your ~/.vimrc Feb 4, 2015 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.