sk1418
March 17, 2011, 10:10am
1
Hi all
What I want?
I want in Insert mode, press Alt-hjkl move cursor, and then back to insert mode.
I know ctrl-o, hjkl can do the job. but everytime I want to move, i have to press ctrl-o, or I have to count how many hjkl I will do, do a C-O (n)hjkl.
What I tried (example only with 'j')
imap <A-j> <down>i
imap <A-j> <esc>ja
imap <A-j> <c-o>j
none of them worked. moving cursor is ok, but cannot bring me back to insertMode.
I am not good at vim script or vim config, can anyone give me a hint, how can I do the mapping?
thanks in advance.
sk1418
March 18, 2011, 7:19pm
3
problem solved.
in fact, gvim works in any case. the mapping cannot bring me back to insert mode only in tty/console.
I used keycode mapping, and it worked both with and without gui.
set timeout
set timeoutlen=1000
"set ttimeout
set ttimeoutlen=50
if !has("gui_running")
set <F14>=<ESC>h
set <F13>=<ESC>j
set <F15>=<ESC>k
set <F16>=<ESC>l
inoremap <F14> <left>
inoremap <F13> <down>
inoremap <F15> <up>
inoremap <F16> <right>
else
inoremap <A-h> <left>
inoremap <A-j> <down>
inoremap <A-k> <up>
inoremap <A-l> <right>
endif