According to the :help startup-options, this is -w's behviour
-w {scriptout} All the characters that you type are recorded in the file
"scriptout", until you exit Vim. This is useful if you want
to create a script file to be used with "vim -s" or
":source!".
Specifically, it mentions the -s flag as a useful application of -w's output.
Testing this, it seems there isn't a 1-1 mapping of the two flags.
For all standard keycodes, -s behaves as expected when running -w's output.
However, when "special" keycodes are used when running with -w (e.g. <Del>, <Up>, ...), Vim will output a special abstraction of these keycodes, that according to the documentation is a terminal-independent representation - for example, <Del> is written in -w's output as <80><6b><44> (hexa) (<80>kD).
I expected Vim's behaviour to interpret the above sequence (<80><6b><44>) as <Del> when it is part of -s's input, but that is not the case. It appears to do something different which I have not been able to fully decipher yet.
Am I trying to use -s in ways that are not intended? Or perhaps there is some hidden Vim option to make this work? Or is it simply a bug in Vim?
Any input will be greatly appreciated, thanks!
Update
Some details I gathered:
<80>is interpreted as a literal<80>through-s, which ends up as<80><fe>X. I don't think this is the intended behaviour.- The suggestion to use
execute 'normal!'ended up not being suited for my use case as macros are disabled when running throughnormal.
My use case actually required "replaying" user input for a fork of a python implementation of the vimgolf client :) (https://github.com/dankilman/vimgolf).
I ended up using feedkeys("<key sequence>", 't') which met all my requirements.
-woutput so you'll get<Del>. I wonder if putting that throughvim -swould result in expected behavior. – B Layer Dec 23 '19 at 22:25<Del>through-swill actually interpret it as the actual keys:<,D,e,l,>:) – dankilman Dec 23 '19 at 23:38-sexactly zero times in my life. :D I was thinking it parsed along the lines of mapping and/or expression parser. :P – B Layer Dec 24 '19 at 03:09I expected Vim's behaviour to interpret the above sequence (<80><6b><44>) as <Del>Looks likesource!fully expects only text input. But note that this seems to work okay::execute 'normal!' readfile('scriptout', 'b')[0]– Matt Dec 24 '19 at 05:30-sdirectly would have been cleaner for my use case, but this solution works perfectly! Many thanks. – dankilman Dec 24 '19 at 13:01