tags:

views:

113

answers:

2

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?

A: 

Pardon me for saying so, but how useful would be to have them work as in normal mode. I mean, what would you use for typing hjkl then?

But, if you really want to map them, sure, just map them with <imap> <something-h> <some operation> and off you go.

Although I see no point. If you want to keep your hands on the middle of the keyboard, why not map jj to <Esc> (some prefer that way, so they don't have to move their fingers off the home row).

ldigas
I do have jj mapped to esc actually, and finding a convenient <something-h|j|k|l> that does work well is my question
dimus
@dimus - Well, there aren't that many of options. If we take the assumption that you won't be mapping the hjkl in insert mode to movement, then you're stuck (on most machines) with Ctrl, Alt and Shift (which is also impractical) combinations. Mind you, I still don't see why would you want movement in insert mode (as a 10 years old vimmer, I gather you would've gotten used to "write in insert mode, everything else in N and E modes" routine, but to each his
ldigas
own. In vim practically you can map anything that gives a signal when pressed in combination with something else (that means no, <A-9> for example), so ... the rest is up to you.
ldigas
Map function keys if you're using a laptop (they're "easier" to reach then arrow keys on most laptop keyboards) for example.
ldigas
I do use movement keys in insert mode when it feels faster than going to normal mode and back to insert mode, that is my use case.
dimus
@dimus - Well, anyways ... I gave you your options. There aren't many of them, all together. You can either use Vim in the way it was ment to be used (that persumes movement and pretty much everything else 'cept the typing, in N mode), or try to modify it to yourself with the few combinations you've got. In my experience, the more people try to modify Vim out of the way it was designed, the more problems they have with it, and after a time, they usually move to something else (Emacs? Notepad++?) ...
ldigas
+1  A: 

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.

mb14