Here's a sample macro.
2Ea,^[j^
(Jump to the end of the second word, append a "," escape visual mode, and go to the next line.)
Instead of 99 The,
I get 99 The,ê^
and it stays stuck in insert mode.
Any ideas?
I've tried manually rewriting the macro like:
2Ea,<Esc>j^
2Ea,<Escape>j^
And neither work, I just end up with something like this: 99 The,<Esc>
silent! exe "set <M-j>=\ej"
andset ttimeoutlen=2000
. In your Vim session, what is the output of:echo &ttimeoutlen
? Have you defined mappings using the Alt modifier key ? Is your problem still there if you restart Vim with a minimum of initializationsvim -u NORC -N
? – saginaw Jan 27 '16 at 10:18'timeout'
, neither'timeoutlen'
nor'ttimeoutlen'
, but the command I mentionedexe "set <M-j>=\ej"
. As soon as I type it, I experience the same issue as you. I had similar commands in my vimrc in the past because I wanted to use mappings with the Alt modifier key... – saginaw Jan 27 '16 at 16:07{lhs}
uses the Alt key. See here for a confirmation: vi.stackexchange.com/a/6021/4939 But I removed most of them because I've discovered they break too many things, including the replay of a macro. If I launchcat
in my shell and type<A-j>
, it displays^[j
. So<A-j>
produces the sequence of keycodesEscape
+j
. When Vim receives this sequence of keycodes, it doesn't know if you typed<A-j>
or the characterê
. Why? It's complex... – saginaw Jan 27 '16 at 16:07Escape
+j
must be interpreted as<A-j>
, I have the exact same issue as you. And if I "unteach" Vim what<A-j>
is (exe "set <M-j>="
), the problem disappears. On my machine, the options'timeoutlen'
and'ttimeoutlen'
have nothing to do with the problem. They control how much time Vim will wait for respectively a sequence of keystrokes in a mapping, and a sequence of keycodes. – saginaw Jan 27 '16 at 16:07'ttimeoutlen'
is because I thought that by reducing the length of the timeout for keycodes on your machine, you would increase the chance for Vim to interpretEscape
andj
as 2 separate keystrokes instead of a single sequence of keycodes. I typed the command you mentionedset timeoutlen=0 ttimeoutlen=-1
. But on my machine it breaks all my mappings because if'timeoutlen'
's value is 0, when I type the first character of a mapping Vim doesn't wait anymore for the next one. – saginaw Jan 27 '16 at 16:08