问题
I admit that I'm not an expert vim
user so forgive me not providing previous attempts!
I wish to overwrite/remap the basic vi
/vim
(and gvim
) "cursor keys" hjkl to the ordinary "gamer layout" wasd (w-up, a-left, s-down, d-right). Moreover: I know that "w", "a", "s" and "d" are important keys in vim
so I came up with the idea to remap hjkl to ALT + wasd.
Have to configure .vimrc? Or is there some plugin? Can you help me?
回答1:
Map your Alt + aswd to hjkl; in your .vimrc
noremap <A-a> h
noremap <A-s> j
noremap <A-w> k
noremap <A-d> l
回答2:
According to zarak's and dNitro's solutions, in my case adding
noremap <Esc>a h
noremap <Esc>s j
noremap <Esc>w k
noremap <Esc>d l
to .vimrc
solved the problem.
Because in my case
cat
ALT-w
ALT-a
ALT-s
ATL-d
resulted ^]w ^]a ^]s and ^]d.
Thanks a lot!
回答3:
I think adding this to your .vimrc should do the trick.
noremap ^[a h
noremap ^[s j
noremap ^[w k
noremap ^[d l
来源:https://stackoverflow.com/questions/38182952/vim-set-cursor-keys-hjkl-to-wasd