In Vim it is nice to use hjkl in normal mode and would be great to continue to use them in insert mode. I tried to map them to Ctrl-h, Ctrl-j, Ctrl-k, Ctrl-l:
imap <C-h> <left>
imap <C-j> <down>
imap <C-k> <up>
imap <C-l> <right>
but it is not convenient especially because it masks Ctrl-H and backspace stops responding. Have you been able somehow to use HJKL keys for movements in insert mode?
To go into INSERT mode from COMMAND mode, you type i . To go back to COMMAND mode, you type the esc key. vim starts out in COMMAND mode. Over time, you will likely spend more time in COMMAND mode than INSERT mode.
Creating keymaps To map a sequence of keys to execute another sequence of keys, use the ':map' command. For example, the following command maps the <F2> key to display the current date and time. The ':map' command creates a key map that works in normal, visual, select and operator pending modes.
I'm using double upper case mapping in insert mode for various mapping. That works pretty well, except when you are pasting text from somewhere. It's usually wiser to clear all insert mappings before inserting text.
So you can try
imap HH <left>
imap JJ <down>
etc...
Obviously , you will need twice key strokes as the normal move, so I guess if you need to navigate "far away" it's better to go back in navigation mode.
I have mapped my normal mode arrow keys to 'bubble' text around. It is very useful for moving blocks of code or text around with minimal effort.
" Useful bubble text normal mapping for arrow keys.
nnoremap <UP> ddkP
nnoremap <DOWN> ddp
vnoremap <DOWN> xp`[V`]
vnoremap <UP> xkP`[V`]
Definitely inspired by Drew Neil's episode on Bubbling Text on VimCasts.org.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With