Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim commands log

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.

like image 984
cutalion Avatar asked Mar 11 '12 21:03

cutalion


People also ask

How do I find vim command history?

Press Ctrl+F in command mode to open the command history window. Then, you can use / , ? , and other search commands. Press Enter to execute a command from the history.

Does vim have history?

Vim text editor is capable of recording the history of all the commands that we enter on the command line prompt. There are two ways of recalling the command history: dialling up the command line window or scrolling through the past command lines using the cursor keys.

What shortcut you use to find a previously ran command in vim?

Entering colon : then ctrl+p shows your previous command, i.e., moving backward through your vim command history. ctrl+n moves forward. This is very convenient if you're used to using the command line and prefer not to change your keyboard hand positioning to use arrow keys.


2 Answers

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.

like image 126
Sethish Avatar answered Oct 05 '22 22:10

Sethish


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.

like image 38
Rook Avatar answered Oct 05 '22 23:10

Rook