Perform diff as exact line match

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Perform diff as exact line match

Ritmo2k
Does a means or plugin exist to perform a diff between two tabs/files that compares entire lines?

Thanks.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Perform diff as exact line match

Tony Mechelynck
On Fri, Jun 29, 2018 at 3:30 AM, Joseph L. Casale <[hidden email]> wrote:
> Does a means or plugin exist to perform a diff between two tabs/files that compares entire lines?
>
> Thanks.

No plugin required, provided that you have a Vim compiled with +diff
and that the diff utility is installed and can be found on your $PATH.

See ":help diff.txt"

Best regards,
Tony.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Perform diff as exact line match

Ritmo2k
On Thursday, June 28, 2018 at 7:46:51 PM UTC-6, Tony Mechelynck wrote:
> No plugin required, provided that you have a Vim compiled with +diff
> and that the diff utility is installed and can be found on your $PATH.
>
> See ":help diff.txt"

Hi Tony,
Specifically, I need to match lines completely ignore partial differences.
I have the most recent version of vim with a diff utility, however I do not
see anything diff.txt or diffopt that allows me to specify matches must be
complete lines and not partial.

I am trying to compare collections of strings, where I am not interested in
similar items, only exact. The collections are sorted so I want to see
filler where an exact line match is not found.

Thanks.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Perform diff as exact line match

Gary Johnson-4
On 2018-06-29, Joseph L. Casale wrote:

> On Thursday, June 28, 2018 at 7:46:51 PM UTC-6, Tony Mechelynck wrote:
> > No plugin required, provided that you have a Vim compiled with +diff
> > and that the diff utility is installed and can be found on your $PATH.
> >
> > See ":help diff.txt"
>
> Hi Tony,
> Specifically, I need to match lines completely ignore partial differences.
> I have the most recent version of vim with a diff utility, however I do not
> see anything diff.txt or diffopt that allows me to specify matches must be
> complete lines and not partial.
>
> I am trying to compare collections of strings, where I am not interested in
> similar items, only exact. The collections are sorted so I want to see
> filler where an exact line match is not found.

I _think_ I understand what you want, but I don't know of a way to
make Vim's internal comparison algorithm do that.

Either of these two Linux commands will generate an output of only
the lines common to file1 and file2, if that helps.

    diff --changed-group-format= file1 file2
    comm -12 file1 file2

The comm command requires that the two files be sorted, but that's
what you have.

HTH,
Gary

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Perform diff as exact line match

Ritmo2k
On Friday, June 29, 2018 at 8:57:45 AM UTC-6, Gary Johnson wrote:

> I _think_ I understand what you want, but I don't know of a way to
> make Vim's internal comparison algorithm do that.
>
> Either of these two Linux commands will generate an output of only
> the lines common to file1 and file2, if that helps.
>
>     diff --changed-group-format= file1 file2
>     comm -12 file1 file2
>
> The comm command requires that the two files be sorted, but that's
> what you have.
Hi Gary,
That's insightful but is the side-by-side comparison I was hoping for in
vim so I could visually assess how the collections differed.

Thanks for the follow up.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Perform diff as exact line match

arocker

>>     diff --changed-group-format= file1 file2
>>     comm -12 file1 file2
>>

> That's insightful but is the side-by-side comparison I was hoping for in
> vim so I could visually assess how the collections differed.
>

Pipe into less? E.g.  comm -12 file1 file2 | less

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Perform diff as exact line match

Tim Chase
In reply to this post by Ritmo2k
On 2018-06-28 18:30, Joseph L. Casale wrote:
> Does a means or plugin exist to perform a diff between two
> tabs/files that compares entire lines?

I've occasionally hacked this by inserting a unique tag (usually just
an incrementing number) after each line in the file, something like

  :windo g/^/put='Unique line: '.((line('.')/2)+1)

which gives fixed boundaries for the diff algorithm to sync up with
after every line.

It's a hack, and it's far from perfect, but it's helped in the couple
occasions I've wanted it.

-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

---
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Perform diff as exact line match

Arun
In reply to this post by Ritmo2k
On Fri, Jun 29, 2018 at 6:19 AM, Joseph L. Casale <[hidden email]> wrote:
On Thursday, June 28, 2018 at 7:46:51 PM UTC-6, Tony Mechelynck wrote:
> No plugin required, provided that you have a Vim compiled with +diff
> and that the diff utility is installed and can be found on your $PATH.
>
> See ":help diff.txt"

Hi Tony,
Specifically, I need to match lines completely ignore partial differences.
I have the most recent version of vim with a diff utility, however I do not
see anything diff.txt or diffopt that allows me to specify matches must be
complete lines and not partial.

I am trying to compare collections of strings, where I am not interested in
similar items, only exact. The collections are sorted so I want to see
filler where an exact line match is not found.
 
You mean you want to find only lines added and deleted, not changed? If
that is the case, perhaps you can script it such that you skip over "changed"
highlight areas, by repeatedly traversing diffs via "]c" or "[c". This can be
achieved by using vim functions diff_hlID() and synIDattr(). I had posted a
script sometime ago that searches for the exact changed text within a 
changed line using the above logic. You can modify that to suit to your needs.

Regards,
-Arun

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Perform diff as exact line match

Gary Johnson-4
In reply to this post by arocker
On 2018-06-29, arocker wrote:
> >>     diff --changed-group-format= file1 file2
> >>     comm -12 file1 file2
> >>
>
> > That's insightful but is the side-by-side comparison I was hoping for in
> > vim so I could visually assess how the collections differed.
> >
>
> Pipe into less? E.g.  comm -12 file1 file2 | less

There's also sdiff:

    sdiff file1 file2 | less

or

    sdiff file1 file2 | vim -

Regards,
Gary

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Perform diff as exact line match

Ritmo2k
On Friday, June 29, 2018 at 10:55:25 AM UTC-6, Gary Johnson wrote:
> There's also sdiff:
>
>     sdiff file1 file2 | less
>
> or
>
>     sdiff file1 file2 | vim -

That worked brilliantly!
Thanks.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.