On 07/27/2011 06:43 AM, Eric Smith wrote:
Is it possible to access the text added to a document within the last
n seconds?

So I want the effect of this;
If I did a checkin to version control periodically, and then I produced a diff
for each period I was interested in.

(I am more interested in the added text than changed text, but this is
not an important point.)

Depending on the granularity, Vim comes with an easy way to diff the current file's contents with it's stored-state on disk:

  :help :DiffOrig

If you want to check a state since the file on disk but earlier than the current state, you'd have to do something like (dependent on your 'undolevels' supporting enough undos to get back to this point in history)

  :earlier 3m
  :%y
  :later 3m
  :diffthis
  :vnew
  :set bt=nofile
  :$p
  :1d_
  :diffthis

where "3m" is 3-minutes (units in undos, seconds, minutes, or hours) as detailed at

  :help :earlier

This could be wrapped up in a mapping/function to make it less onerous, just taking the units you want. It just goes back in time to the point you want, copies the contents of the file, returns to the most current version, creates a new buffer populating it with the old/historical contents, and then diffing the two buffers.

-tim





--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to