Using VIM, how do I remap directional keys from right hand to left hand?

3

1

This is the best solution I've seen so far:

" Map Right Directionals to Left Commands
noremap s h
noremap d k
noremap f j
noremap g l

" Map Left Commands to Right Directionals
noremap h s
noremap k d
noremap j f
noremap l g

However, when actually using this mapping, it requires a double-press on the 's' and 'g' keys when switching from left to right.

Is there a better way to re-map these keys to work 100% correctly without the need to double-press keys?

Masao Kitamura

Posted 2012-04-04T19:13:25.493

Reputation: 31

Spontaneously I don't really see the application. It's just a question of habit - if you are used to using your right hand for movement keys, this will be the most convenient, left-handed or not. In games the standard is to use the left hand for movement (WASD), and I as right-handed have no trouble with this. Normally I think getting used to custom keyboard shortcuts is mostly unnecessary, and annoying when one has to use someone else's settings for any reason. Allright, I'll stop rambling aimlessly now :-) . – Daniel Andersson – 2012-04-04T19:53:35.600

Did you manage to find a solution for this problem? – Ivo Flipse – 2012-07-15T17:34:26.020

Answers

1

The mappings work for me in a plain Vim (vim -N -u NONE); you probably have some other mappings that start with s or g, and therefore Vim has to wait for a next keypress to resolve the ambiguity. Check for such mappings with

:verbose nmap s
:verbose nmap g

and remove / redefine those mappings.

Ingo Karkat

Posted 2012-04-04T19:13:25.493

Reputation: 19 513

0

You should give a try to nnoremap it prevents recursive mappings.

Jacek Wysocki

Posted 2012-04-04T19:13:25.493

Reputation: 113

I tried nnoremap but it doesn't change the results...still need to double-press left and right keys when switching directions. – Masao Kitamura – 2012-04-07T03:02:02.143