I use vim for coding and also for writing scientific articles and book chapters.
It would be very interesting to know the time I spent on a file. For example how many hours or minutes the buffer was open in total, per day, etc.
Ideally, one also could see the writing speed (I use Colemark and Steno/Plover for writing).
I did not find a suitable plugin; is there one? How could I build my own 'academic writers' plugin?
I mainly program in Python, but I would adjust to other programming languages, if necessary (I am co-author of Pandoc-Scholar).
BufEnter
andBufLeave
to start and stop a timer, keep a track of the time spent in each buffer with buffer-local variables, dump the whole stats in a global variable and write that to a file. Then you'd have an external program or a custom command to consolidate everything to have time per day. The writing speed would be harder to do because it's not trivial to keep track of exactly what you modified and at which pace. That sounds like a cool plugin idea!vim-chronos
and decided to duck it just to be sure and I found chronos it doesn't look exactly what you are looking for but it could be an interesting basis. The point about not being able to detect when your terminal vim looses focus sounds quite important.