I'm trying to keep track of my hours for work, and I have to keep very specific details of which files I was editing and when. In my .vimrc script, I have:
:silent !clock_in_script.sh %:p
This clock_in_script.sh takes the location of the file as an argument and just writes the name of the file and time to a log.
Is there a way to similarly invoke a script when I exit vim? If not, is there a way I can write the name of the file I'm editing and the time to a logfile from vim?
Thank you in advance!
there is an event VimLeave
(:h VimLeave) is for the requirement you described.
However, this may not work for your needs. Because you may open many files in one vim instance. I use vim always in this way. In this case, you can only save the status of current buffer/file.
You can :h event
to check out the events vim's autocommand supports. Also consider to write a small function to loop all buffers and call your command. or modify your shell script to accept more than one filename as parameter, so that you can call the script only once.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With