vimdiff exit when files are identical?

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

vimdiff exit when files are identical?

M Kelly
Hi,
Is there a variable for how many diffs are present after starting vimdiff ?
I'd like to exit immediately with status of 0 if there are no differences between the files I pass into vimdiff.
thx for any suggestions,
-mark

--
--
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: vimdiff exit when files are identical?

Tim Chase
On 2018-05-28 18:11, M Kelly wrote:
> Is there a variable for how many diffs are present after starting
> vimdiff ? I'd like to exit immediately with status of 0 if there
> are no differences between the files I pass into vimdiff.

Not that I know of off the top of my head (though if there is, I'd be
glad to stash that new knowledge away), but you can do a quick check
before invocation:

  diff -q file1 file2 >/dev/null && echo same || vimdiff file1 file2

which could be wrapped in an alias/function to simplify the
invocation.

-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: vimdiff exit when files are identical?

Bram Moolenaar

Tim Chase wrote:

> On 2018-05-28 18:11, M Kelly wrote:
> > Is there a variable for how many diffs are present after starting
> > vimdiff ? I'd like to exit immediately with status of 0 if there
> > are no differences between the files I pass into vimdiff.
>
> Not that I know of off the top of my head (though if there is, I'd be
> glad to stash that new knowledge away), but you can do a quick check
> before invocation:
>
>   diff -q file1 file2 >/dev/null && echo same || vimdiff file1 file2
>
> which could be wrapped in an alias/function to simplify the
> invocation.

Another way would be to check the fold regions.

--
The process for understanding customers primarily involves sitting around with
other marketing people and talking about what you would to if you were dumb
enough to be a customer.
                                (Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
--
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: vimdiff exit when files are identical?

M Kelly
> Another way would be to check the fold regions.

Any pointer/info/tip on how to determine the non-fold region is empty ?

thx,
mark

--
--
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: vimdiff exit when files are identical?

Gary Johnson-4
On 2018-05-30, M Kelly wrote:
> > Another way would be to check the fold regions.
>
> Any pointer/info/tip on how to determine the non-fold region is empty ?

I think this will do it.

    if foldclosedend(1) == line("$")
        " Entire buffer is a closed fold
    endif

See

    :help foldclosedend()

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.