zdd
zdd

Reputation: 8747

How to let vim keep in insert mode when pressing Alt - h to move in insert mode?

In order to edit fast in insert mode, we can use mapping keys to navigate in insert mode, for example

:inoremap <A-h> <Left>

with this mapping, user can press Alt + h in insert mode to let the cursor move left and then do insert, we don't need to exit edit mode, then move cursor. this will save some time for us, my question is when I use this mapping key, the cursor moves correctly, but vim switch to normal move after moving, it should keep in insert mode, I use vim 7.3 in Sun OS. I tried this in gvim 7.3 on windows, everything is good, so I wondered is there anything i lost?

Upvotes: 2

Views: 901

Answers (2)

zdd
zdd

Reputation: 8747

I got the answer here, http://vim.wikia.com/wiki/Fix_meta-keys_that_break_out_of_Insert_mode, this will happened on Unix or Putty.

Upvotes: 1

Amadan
Amadan

Reputation: 198436

First of all: if you think navigation in insert mode is speeding up your vim, you're using it wrong (i.e. like any other non-modal editor, when its biggest benefit is specifically modality).

That said, we can't say too much without you showing us your mapping. I suspect it is something like this:

inoremap <M-H> <Esc>h

Try changing to

inoremap <M-H> <C-O>h

Upvotes: 2

Related Questions