9

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.

cutalion
  • 4,334
  • 1
  • 38
  • 47

2 Answers2

14

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.

Sethish
  • 364
  • 2
  • 12
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.

Rook
  • 60,248
  • 49
  • 165
  • 242
  • 1
    I'd like to collect statistics of my vim usage during a day (or even a week or month). And I can forget to start recording a macro :). Also I'm using macros sometimes, and I can forget to re-start recording. But I like the idea - will give it a try. – cutalion Mar 11 '12 at 21:22
  • 2
    @cutalion - "statistics of your vim usage during a day" ? For what purpose? Sorry, I think a keylogger in that case will be your only viable alternative. – Rook Mar 11 '12 at 21:34
  • 2
    @cutalion Macros record into a register, so `:reg a` will print the macro a on the screen, and `"ap` will paste it into the document etc. – Neil Mar 11 '12 at 21:35