I am writing a very small script in VimL and I am looking to simulate actual typing of a given string.
The problem I am facing is that anything I try places the whole string instantly on the buffer, so the whole operation looks quite atomic and it doesn’t portray the natural latency of char-by-char of typing.
I’ve tried a few variations of the function below, and even though I’ve added a sleep 50m at different places, I don’t get the desired behavior:
function! FakeTyping(string)
let list = split(a:string)
for word in list
for letter in split(word)
execute "normal a" . letter . "\<esc>"
endfor
endfor
endfunction
Is this even possible? and if so, what is it that I am missing?
Maybe this is what you need. You hit Ctrl–MiddleMouse to send the content of clipboard to vim char by char: