On Do, 01 Dez 2022, Salman Halim wrote:
> Hello,
>
> Is it possible, either natively or through Vim script (I'm happy to write the
> code, but not sure what to look for), to get a list of the lines that have been
> changed since a particular moment?
>
I would use one of the undo plugins (like gundo python or undotree
vimscript) plugins for this. I think they also show the diff between
versions.
I even created a plugin histwin when the persistence undo feature was
introduced, that allowed you to tag certain states and allowed to show
you the diff between states
Best,
Christian
--
--
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
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20221201155216.GC472721%40256bit.org.
I believe gundo provides a way to directly show the diff between various
undo states¹ and I think you are right, the only way to do this is to
manually safe the state of the buffer and run a diff over that file with
the current buffer. I don't think there is an simpler way than that.
¹) see e.g. https://simnalamburt.github.io/vim-mundo/#usage and search
for preview pane
Best,
Christian
Does :h changes help?
On Thu, Dec 1, 2022 at 5:04 PM Salman Halim <salma...@gmail.com> wrote:
On Thu, Dec 1, 2022, 15:32 Owajigbanam Ogbuluijah <xigb...@gmail.com> wrote:
Does :h changes help?
I hadn't thought to look at that. That's interesting. I suspect I'm going to just do the diff stuff similarly to Mundo (as suggested by Christian) or Gundo because I need an exact list of lines that were added or changed, but want to skip any that were deleted.
[...]
Basically, I can't check the entire file after every save. I need to have some way of restricting the diff regions.
1) Vim can diff contents of buffers that are not associated with
physical files. On detecting a save, from the change list get the
lines of interest in the previous and current version; then
appendingly-yank the regions of interest in the current buffer and
likewise appendingly-yank the corresponding regions in the saved
file; and then open a new buffer that compares the yanked stuff.
(I don't mean do these steps manually, but via a script.)
2) I came late to this thread and do not know if comparing an entire file but restricting the display via folds meets your needs. If so, one could detect a save command and write a script that opens a new buffer that visually compares the previous and current versions with unchanged regions folded and the ability to jump to changes via ]c and [c.
--Suresh
1) Vim can diff contents of buffers that are not associated with physical files. On detecting a save, from the change list get the lines of interest in the previous and current version; then appendingly-yank the regions of interest in the current buffer and likewise appendingly-yank the corresponding regions in the saved file; and then open a new buffer that compares the yanked stuff. (I don't mean do these steps manually, but via a script.)
2) I came late to this thread and do not know if comparing an entire file but restricting the display via folds meets your needs. If so, one could detect a save command and write a script that opens a new buffer that visually compares the previous and current versions with unchanged regions folded and the ability to jump to changes via ]c and [c.
--Suresh