
Icdiff: Side-by-side highlighted command line diffs - stepstop
https://www.jefftk.com/icdiff
======
jez
Another little known diff power tool:

    
    
        vim -d old.txt new.txt
    

This will open two files in diff mode. You can then use a whole host of fancy
keybindings to edit the two files in a diff-aware way ("apply this hunk to
that file" / manually edit a file and then re-render the diff / "fold or
expand all non-hunk text" / etc.). For more:

    
    
        :help diff
    

or see here
[https://neovim.io/doc/user/diff.html](https://neovim.io/doc/user/diff.html)

~~~
heeen2
I am a big fan of the patchreview plugin, I use it every day. It opens a
multifile diff (e.g. git diff patch output) each file in a vim tab.

[https://github.com/junkblocker/patchreview-
vim](https://github.com/junkblocker/patchreview-vim)

$ gvim -c"DiffReview git diff origin/master"

------
bno1
A similar tool that I really like is meld
([https://meldmerge.org/](https://meldmerge.org/)). It has a GUI, really nice
visual indicators, allows you to view the entire file and directory trees and
you can jump between diff chunks using alt + arrow up/down.

I often use it with git:

git difftool -t meld -d

~~~
wffurr
How is that similar? It's a GUI. There's a zillion GUI diff tools but very few
console ones. icdiff is the only side by side CLI diff tools I have seen.

~~~
js2
sdiff has been around forever:

[https://linux.die.net/man/1/sdiff](https://linux.die.net/man/1/sdiff)

It’s not a three-way diff and not highlighted however. (icdiff doesn’t seem to
be a three-way diff either.)

------
NateEag
Delta is a similar tool with syntax highlighting for most programming
languages and customizable themes:

[https://github.com/dandavison/delta](https://github.com/dandavison/delta)

It doesn't have side-by-side diffs, but it's still well worth having around.

It's a Unix filter, so it works on any unified diff you can come up with.

Its default output isn't a unified diff, but that's easy to fix with its
configuration / CLI options (I'm too used to reading unified diffs to like
delta's simplified default format).

------
e12e
This looks nice, but is it very different from gnu(?) diff --color=always
--side-by-side?

~~~
jefftk
Could you share a screenshot? When I run GNU diff with --side-by-side, it
seems that --color=always is ignored: [https://www.jefftk.com/gnudiff-color-
always-side-by-side.png](https://www.jefftk.com/gnudiff-color-always-side-by-
side.png)

~~~
e12e
[https://postimg.cc/4Y2Jh6pz](https://postimg.cc/4Y2Jh6pz)

~~~
jefftk
Thanks! After playing with diff --color=always --side-by-side more, it looks
like it colors inserted and deleted lines but not changed lines:
[https://www.jefftk.com/icdiff-vs-diff-color-always-side-
by-s...](https://www.jefftk.com/icdiff-vs-diff-color-always-side-by-side.png)

(And it still doesn't find changes within a line)

~~~
e12e
I think, for changes within a line, wdiff would be the usual tool - but even
if it's possible to pipe that through colordiff - I don't think there's a
side-by-side mode for wdiff.

But yeah, I see that in-line highlighting of changes can be helpful sometimes
:)

------
mixmastamyk
I've been using `alias diff=colordiff` for maybe twenty years. Looks like
icdiff can highlight small changes without needing to call out the whole line.
Is there anything else new this one brings?

~~~
jefftk
Screenshots:

* colordiff -y: [https://www.jefftk.com/colordiff-y-example-simple.png](https://www.jefftk.com/colordiff-y-example-simple.png)

* icdiff: [https://www.jefftk.com/icdiff-example-simple.png](https://www.jefftk.com/icdiff-example-simple.png)

The two main differences I see are that icdiff can highlight the affected
portions of lines, and that icdiff makes better use of horizontal space.

~~~
mixmastamyk
I see. Also, I'd configured colordiff to use green and red as well.

------
fphilipe
If you're used to Git's diff view and want to use it for any two files outside
of a repo, you can do

    
    
        $ git diff --no-index file_a file_b

------
warkdarrior
colordiff -y [[https://www.colordiff.org/](https://www.colordiff.org/)] has
similar functionality.

~~~
Lio
Another alternative: Kitty-diff

It’s terminal specific as it uses kitty’s graphics extensions but it looks
really IMHO.

[https://sw.kovidgoyal.net/kitty/kittens/diff.html](https://sw.kovidgoyal.net/kitty/kittens/diff.html)

------
auraham
This is a really useful utility. This post explains how to use it with
mercurial for better diffs:

[https://ianobermiller.com/blog/2016/07/14/side-by-side-
diffs...](https://ianobermiller.com/blog/2016/07/14/side-by-side-diffs-for-
mercurial-hg-icdiff-revisited/)

------
pabs3
I like diffoscope's side-by-side HTML diffs of arbitrary files/dirs, for eg:

[https://diffoscope.org/](https://diffoscope.org/)
[https://diffoscope.org/examples/https-
everywhere-5.0.6_vs_5....](https://diffoscope.org/examples/https-
everywhere-5.0.6_vs_5.0.7.html)

------
tutfbhuf
I wish Icdiff had syntax highlighting for common programming languages.

~~~
wffurr
Wouldn't the syntax coloring interfere with the diff coloring? Is there an
example of a tool that does both?

~~~
rgoulter
At least one of the other tools in this thread does both. (Rather than
visualising add/rm with the foreground, it's visualised with the background
colour).
[https://github.com/dandavison/delta](https://github.com/dandavison/delta)

~~~
tutfbhuf
Yes, but delta doesn't have side-by-side diff. Is someone aware of a command
line util, that has side-by-side diff and syntax highlighting? I know that
Gitlab can do that.

~~~
Liquid_Fire
vimdiff does that.

~~~
tutfbhuf
True, but vimdiff is a wrapper around vim, that starts the editor with pre-
arranged windows. I would like to have a non-interactive stand-alone tool,
that prints the syntax highlighted side-by-side to the terminal then exits and
does not require you to learn vim. Maybe such a thing does not exist yet and I
have to wait for delta issue #86 to happen.

------
yboris
Related: _diff2html_ CLI that will open your browser to a beautifully-rendered
HTML diff:

[https://diff2html.xyz/](https://diff2html.xyz/)

------
zestyping
ydiff might be the tool you're looking for.

[https://github.com/ymattw/ydiff](https://github.com/ymattw/ydiff)

~~~
ncr100
Ydiff is GIT aware. It made me :) recently when I needed to diff a 6 month
branch divergence.

------
splittingTimes
In your experience, What's the best tool to check 3-way merge diffs under
windows?

~~~
wayneftw
Beyond Compare

~~~
donatj
It really does live up to it's name in my opinion. Been using it for over a
decade, originally in Windows but now macOS

