In order to move the cursor in insert mode, I add the following key maps in my .vimrc(I use vim 7.3 on Sun OS)

inoremap <Alt-h> <Left>
inoremap <Alt-j> <Down>
inoremap <Alt-k> <Up>
inoremap <Alt-l> <Right>

When I press the mapping keys, the cursor moves correct, but vim will quit insert mode and switch to normal mode, what's wrong with my vim? I also tried this with my gvim on Windows, it works well. Did I lost any options for the mapping keys?

2 Answers 2


Some terminal emulators generate escape sequences for meta (alt) characters. Alt-A becomes <esc>a. This is usually a problem on *nix machines.

You can find out more details here:



It's not a solution, but a workaround to your problem might be

inoremap <Alt-h> <c-o>h
inoremap <Alt-j> <c-o>j
inoremap <Alt-k> <c-o>k
inoremap <Alt-l> <c-o>l

:h i_CTRL-O => execute one command, return to Insert mode

If that has the same problem (dropping out of insert mode on Sun OS) the following should work cross platform [unverified claim].

inoremap <Alt-h> <esc>i
inoremap <Alt-j> <esc>ja
inoremap <Alt-k> <esc>ka
inoremap <Alt-l> <esc>la

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .