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?

: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 htns. h is the same, so we need to map the other three:

:set langmap=tj,nk,sl

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

| improve this answer | |
  • 1
    To be fair, Dvorak uses the keys dhtn, not htns, in the place where Qwerty uses hjkl. – Anthony Feb 21 '15 at 17:26

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.

| improve this answer | |
  • 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 '15 at 1:49
  • 1
    you should put this in your ~/.vimrc – Dhruva Sagar Feb 4 '15 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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