Vim: set 'cursor' keys hjkl to wasd

2019-07-28 06:48发布

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?

3条回答
做个烂人
2楼-- · 2019-07-28 06:58

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
查看更多
戒情不戒烟
3楼-- · 2019-07-28 06:59

I think adding this to your .vimrc should do the trick.

noremap ^[a h
noremap ^[s j
noremap ^[w k
noremap ^[d l
查看更多
Rolldiameter
4楼-- · 2019-07-28 07:02

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!

查看更多
登录 后发表回答