0

I have asked a question here about what should I add to .vimrc to map ALT + a to "h"; ALT + s to "j" and so on. The solution is adding the following to .vimrc:

noremap <Esc>a h
noremap <Esc>s j
noremap <Esc>w k
noremap <Esc>d l

Now, my problem is, that this solution does not work in INSERT mode (but works in NORMAL mode). Using imap results like typing h,j,k,l, iunmap results error.

How to set .vimrc to make ALT + wasd works like hjkl "cursor keys" also in INSERT mode?

Community
  • 1
  • 1
Tom Solid
  • 2,226
  • 1
  • 13
  • 32
  • 6
    Learn Vim before wasting too much time in the customization aisle of your local department store. – romainl Jul 04 '16 at 14:10
  • Notice you are using `noremap` here, not `map`. Did you try `inoremap` instead of `imap`? `noremap` is only effective in modes `n`, `v`, `o`, not in `i` (insert) mode. – Dan Lowe Jul 04 '16 at 22:45

1 Answers1

1

To make it work in insert mode you could just add this to your .vimrc

inoremap <esc>a <left>
inoremap <esc>d <right>
inoremap <esc>w <up>
inoremap <esc>s <down>

You have to be careful with this though, because this may conflict with other commands when you're switching out of insert mode. When you for instance want to delete the line you're currently editing, you could do <esc>dd, but with these keybindings you would add a d after the next character.

Morss
  • 33
  • 6