tags:

views:

65

answers:

2

When I start with a blank .vimrc in ~, and add imap jj <esc> to it, everything works fine at first (i.e. typing jj exits from insert mode -> normal mode). But as I add more to my .vimrc, eventually typing jj will skip the cursor ahead some seemingly random, short distance (a couple of words or a couple of lines) in addition to entering normal mode. I haven't pinned it down to any specific thing I've added to .vimrc -- it just at some point goes from working correctly to malfunctioning. Then, if I delete the .vimmrc file, start over again with a new .vimrc with just that mapping, the weird jumping goes away.

Any clues as to what's going on?

edit:

my complete ~/.vimrc

set nocompatible
inoremap jj <esc>

That's it. I've renamed /etc/vim/vimrc & /usr/share/vim/vimrc to vimrc.0, and similarly moved ~/plugins & ~/ftplugins.

:imap & :inoremap both show just i jj * <Esc>

+2  A: 

You may want to use inoremap instead of imap. This will prevent further substitution of your mapping by other mappings. From the vim wikia:

"For simplicity, we will show :imap but careful Vimmers are in the habit of using :inoremap which does not attempt to interpret the result of the mapping (with the :imap command, the result is scanned to see whether it contains another mapping)."

If another mapping contains j however, this could still crop up, even when using inoremap.

Crast
+1  A: 

Another thing to consider in your debugging is the presence of a global vimrc file, often in /etc/vimrc

It's possible that you have a mapping in the global file that conflicts with your user's ~/.vimrc

Andrew