Ubuntu – Difference in behavior of `` and `inoremap jk ` in vim

Ubuntuvim

I just installed Ubuntu 12.04 on a new computer and apt-get install[ed] vim and I'm having some weird behavior with my aliased Esc – if I'm in INSERT mode and I type the Esc key, I exit INSERT mode and the cursor moves one character to the left, as expected, but if I type the jk alias, which I have defined in my .vimrc as inoremap jk <Esc>, I exit INSERT mode and the cursor moves one character to the right, which is actually quite disconcerting. Any ideas as to why this is the case?

Best Answer

I don't think this is because of this rule alone, something else is causing this. If I create a .vimrc file with just this rule in it:

$ more .vimrc
inoremap jk <Esc>

I get the same behavior as expected from both methods.

Example #1 - esc

Invoke vim, go into Insert mode, right arrow 1 time, hit Esc.

   ss of vim w/ esc

Example #2 - jk

Invoke vim, go into Insert mode, right arrow 1 time, hit jk.

   ss of vim w/ jk

Related Question