Friday, December 2, 2022

Re: List of changed lines

On 12/3/2022 6:42 AM, Salman Halim wrote:
On Thu, Dec 1, 2022 at 5:04 PM Salman Halim <salmanhalim@gmail.com> wrote:

On Thu, Dec 1, 2022, 15:32 Owajigbanam Ogbuluijah <xigbanam@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


No comments: