The options 'timeout'
and 'timeoutlen'
control how Vim will treat typed characters when they are part of a mapping. By default 'timeout'
is enabled and 'timeoutlen'
's value is 1000 (ms).
It means that by default when you hit a character that is part of a mapping, Vim will wait 1s before deciding whether you are typing the {lhs}
of your mapping or if it's just a single character.
When you hit the first j
in your mapping, you could imagine that Vim has triggered a timer, and you have 1s to type the second j
if you want to escape. After 1s, your first j
is not considered as part of a mapping anymore, it's just a character. So in the end Vim will just insert jj
.
Usually Vim receives your j
almost immediately after you typed it. However, if your system is under a heavy load maybe it adds some lag between the moment where you hit j
and the moment Vim receives it. When it happens it's as if you typed jj
with more than one second between the 2 characters. If that's the case, then you could increase the value of the 'timeoutlen'
option so that your second j
has enough time to reach Vim before the timeout occurs.
For example, to increase the length of the timeout to 2s, you could add in your vimrc:
set timeoutlen=2000
For more information, see:
:help timeout
:help timeoutlen
'timeout'
and'timeoutlen'
. For example, if you type:set notimeout
or if you increase the value of'timeoutlen'
(let's say to 3s:set timeoutlen=3000
). Does it change anything ? – saginaw Jan 25 '16 at 19:59set notimeout
was a complete bad idea, however slightly increasing the value of'timeoutlen'
might still be worth a try. You could also look at the options'ttimeout'
and'ttimeoutlen'
but normally those only concern key codes not mappings so they shouldn't be useful here. – saginaw Jan 25 '16 at 21:31timeoutlen
has an impact, if you want to post that as the answer I'll accept it. There's also a more complicated method, that doesn't quite suit my needs but is nonetheless interesting, here: vi.stackexchange.com/questions/563/… – Josh Rumbut Jan 26 '16 at 14:22:echo
command, the other Ex commands I tried resulted in an errorE523
. If my answer does not fully solve your issue, feel free to not accept it and to update your question to get more help. – saginaw Jan 26 '16 at 15:20