Vim allows logging all input when the -w
command line option is passed with a file:
-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!". If the {scriptout} file exists, characters are appended.
Now that we have access to the input we can redirect it where we want. The following way for instance (*nix systems only):
vim -w >(./timestamper.py > log)
vim -w >(tee raw-log | ./timestamper.py > log) # If we want the raw log, too
Where timestamper.py
is the following short python script:
#!/usr/bin/env python
import sys
import datetime
while True:
if (sys.stdin.closed):
sys.stdout.write("Input closed\n")
break
a = sys.stdin.read(1)
if (not a):
break
sys.stdout.write("[{}]: {}\n".format(datetime.datetime.now(), a))
The script can be replaced with any other programme that takes input if you want to do something more sophisticated.
NOTE: After some short testing I found out that vim seems to keep a buffer of the inputs that it flushes at some point and on exit. This makes the timestamps fairly unreliable.
-w
flag when you start vim. You can record every keystrokes with it. – nobe4 Sep 3 '15 at 13:10vim -w file.log
) and provides a haskell script to parse the file into separate commands which you can then analyse. No timestamps though. – tokoyami Sep 3 '15 at 13:10vim -w <(./test-io.py > log)
(vim -w <(tee raw-log | ./test-io.py > log)
if you want the raw output, too) (*nix only). This should write all your input with timestamps, one byte per row, inlog
. What I have noticed is that vim doesn't output the commands one by one but flushes them. – tokoyami Sep 3 '15 at 14:00