3

In insert mode alt-hjkl will go to normal mode, i dont want.

I want alt-hjkl move the cursor and stay in insert mode.

So,try add this to vimrc but it doesn't work.

noremap! < A-h > < left >

noremap! < A-j > < down >

noremap! < A-k > < up >

noremap! < A-l > < right >

any ideas ? :)

Community
  • 1
  • 1
Chiakey
  • 131
  • 3
  • 8
  • If that's exactly how you've written it, you've got the syntax (spacing) wrong. Read `:h key-notation` to learn how to do it right. – Ingo Karkat Apr 26 '14 at 11:24
  • if you meant gvim, it is easy... if in terminal.... I was trying to achieve the same, but finally gave up. (`urxvt` terminal) http://stackoverflow.com/questions/5379837/is-it-possible-to-mapping-alt-hjkl-in-insert-mode – Kent Apr 26 '14 at 22:31

2 Answers2

1

Correct usage is:

inoremap <A-h> <left>
inoremap <A-j> <down>
inoremap <A-k> <up>
inoremap <A-l> <right>
mihai
  • 37,072
  • 9
  • 60
  • 86
  • does this work for terminal vim too? :) see here http://stackoverflow.com/questions/5379837/is-it-possible-to-mapping-alt-hjkl-in-insert-mode – Kent Apr 26 '14 at 22:29
  • ah, you're right...oh well, the Alt key is always problematic, I just avoid it...they seem to be working in the terminal on Windows though :) – mihai Apr 27 '14 at 07:16
0

I use xmodmap to achieve such behavior, but I use Caps instead of Alt.

see solution on Superuser.

Community
  • 1
  • 1
Zeitvertreib
  • 119
  • 1
  • 7
  • 1
    The question regards vim, which is not an X application. Why would using xmodmap be relevant? – einpoklum Jan 07 '17 at 18:32
  • Good Point. My suggestion is more of a workaround then a solution. However, it works fine for my Linux, where all my applications are running in X. (also vim started in Terminal-emulator) Also at the point I discovered for my self, that I could use hjkl-movement in any application, I didn't want to go back. And maybe the OP wants to go there next. – Zeitvertreib Jan 09 '17 at 05:27