Vim: strange behavior of "\" in insert mode

0

I'm editing a lot of tex files using vim, and therefore I use the \ character a lot. Yet, when inserting a \ in insert mode, vim pauses the cursor on the same spot for one second, unlike with any other character.

Of course I don't have to physically wait for one whole second, I can just keep on typing, yet the text is only inserted after this second.

I found that I can create similar behavior by mapping e.g.:

inoremap ;; <esc>:
inoremap jj <esc>

etc. It seems as if vim is expecting another character to follow, so it can evaluate the map.

Unsetting \ as the mapleader doesn't alleviate the problem though, which is what I expected.

Also, I don't know if this is related, but using <esc> in insert mode doesn't work instantly (again because vim expects something to come after).

Is there a vim setting that let's me put the paste time to 0, yet I still want to be allowed to use my mappings ;;, jj and <esc>.

I know about timeout yet this doesn't help. If I do timeoutlen=0 none of the multi-key mappings would be useable.

romeovs

Posted 2011-11-06T19:54:26.230

Reputation: 299

Answers

0

You've identified the problem: \ is being used as the first character of an imap. To find out where it is being set you can execute

:verbose imap \

I don't have any solution other than to eliminate the mapping or unmap it when you're editing TeX files. You can do that by putting a line like this in a file named ~/.vim/after/ftplugin/tex.vim on Unix or ~\vimfiles\after\ftplugin\tex.vim on Windows:

silent! iunmap \x

where you would replace x by the corresponding part of the offending mapping.

I use LaTeX a little, have the Vim-LaTeX-Suite installed, and do not see that behavior, so at least it's not a problem with that suite.

garyjohn

Posted 2011-11-06T19:54:26.230

Reputation: 29 085

0

It looks like you have an insert mode mapping starting with "\", possibly set by a plugin you have recently installed. To find if you do, and what file created the mapping(s), run this command:

:verbose imap \

Heptite

Posted 2011-11-06T19:54:26.230

Reputation: 16 267