Vim: set 'cursor' keys hjkl to wasd

依然范特西╮ 提交于 2019-12-11 04:17:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!