问题
Is it possible to log all commands I type in VIM for later analyzing? I mean each simple command like motions or changing the text, i.e. jjjjjjkkkcw<newword>
If it is not possible in VIM, maybe there is a keylogger on linux, which can be attached to specific window/process?
I'd prefer in-vim logging, because it could have options to have different logs for different vim modes. Also I don't want to log "colon" commands.
回答1:
Yes, there is! When launching vim use vim -W ~/vimcommands.log
to >> to a file, or -w
to overwrite the 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. -W {scriptout} Like -w, but an existing file is overwritten.
You may want to add a bash alias to store vim logs based on file name. I am interested to see how you intend to analyse your logs, I would like to do the same.
回答2:
Why not just start recording a macro (qa
for example will start recording a macro in a
), and it will record them all for you?
Ctrl-R a
in insert mode will let you view its contents.
来源:https://stackoverflow.com/questions/9658967/vim-commands-log