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>
^[? Ctrl-V Esc? – muru Jan 26 '16 at 20:21:let @t="2Ea,^[j^"where ^[ was Ctrl-V Esc. Both produced the same result when I run the macro, ê^ – newUserNameHere Jan 26 '16 at 20:25silent! 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:18set timeoutlen=1000 ttimeoutlen=0and when I changed them toset timeoutlen=0 ttimeoutlen=-1it fixed everything! – newUserNameHere Jan 27 '16 at 14:46'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: http://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 launchcatin 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+jmust 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 interpretEscapeandjas 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:08set timeout timeoutlen=3000 ttimeoutlen=100. It's given in:help ttimeoutlen. I think it's a good command because it gives you enough time to type your mapping (3s) but waits only .1s for a sequence of keycodes, which is good because it prevents Vim from interpreting your keystrokes as part of a sequence of keycodes which can be annoying. See here for an example of problem you can encounter when'ttimeoutlen'is too high: http://vi.stackexchange.com/a/3262/4939 – saginaw Jan 27 '16 at 16:08