Vim commands log
Asked Answered
C

2

10

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.

Confute answered 11/3, 2012 at 21:15 Comment(2)
related: #8928570Mcclain
i'm in the process of applying a patch to vim73, looking promisingMcclain
O
15

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.

Openhanded answered 29/5, 2012 at 19:28 Comment(0)
A
3

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.

Alica answered 11/3, 2012 at 21:18 Comment(3)
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.Confute
@Confute - "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.Alica
@Confute 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.Sodalite

© 2022 - 2024 — McMap. All rights reserved.