
Icdiff: side-by-side command line diffs - cbr
http://www.jefftk.com/icdiff
======
givan
I use [http://meldmerge.org](http://meldmerge.org) and besides syntax coloring
it has filters for comments and whitespace, a 3 way file compare and folder
compare that is very useful to see changes between code updates.

~~~
netheril96
Meld is the best diff/merge tool I have tried. But it relies on GTK, which
relies on X, which looks terrible on Mac with retina screen.

~~~
dima55
Clearly the problem here does not lie with Meld.

~~~
scott_karana
I don't think netheril96 blamed Meld at all. Nor OS X.

------
Gonzih
Most of the time I use vimdiff to diff 2 files. Also allows you to push/pull
differences from one buffer to another.

~~~
kolme
Vimdiff also support 3-way diffs.

Git integration with fugitive is also worth mentioning. It makes partial
committing and cherry picking very easy.

Either way, icdiff looks very promising.

------
userbinator
GNU diff has the -y option that already does side-by-side diffs; I'm a bit
surprised that it doesn't do colouring already.

~~~
__michaelg
Just use colordiff, `colordiff -y`works perfectly fine.

~~~
cbr
"colordiff -y" colors whole changed lines: [http://www.jefftk.com/icdiff-vs-
colordiff-y-2x.png](http://www.jefftk.com/icdiff-vs-colordiff-y-2x.png)

------
xixixao
This is great, is there a way to use it with Git?

Edit: It also pains me that this is not the default (or one of the two
default) diff views almost anywhere. The best diff I've used was in
Phabricator. But Google, Github and Git don't have a support for side-by-side
diffs, which I'd argue are the best view in 90% of incremental changes.

~~~
xixixao
Hmm, seems I was overly optimistic. This fails with two words only on one
line, highlights the words "red" and "blue" as being composed of each other
and so on. Back to

git difftool --color-words

~~~
cbr
Sorry, could you give an example input icdiff performs poorly on? I just tried
it on "red" and "blue", and got [http://www.jefftk.com/icdiff-red-
blue-2x.png](http://www.jefftk.com/icdiff-red-blue-2x.png) which seems pretty
reasonable to me.

------
jkaptur
Very cool! I love tools that provide better UX around diff - that show not
just the shortest possible edit script, but a more human-readable output of
what has actually changed. I've been prototyping some ideas in a web app:
[http://diff.so](http://diff.so).

~~~
xixixao
Nice, but you want an option for specifying words (or some sane default like
\b), otherwise you get unreadable output.

~~~
jkaptur
Thanks for the feedback! You're exactly right, tokenizing at the letter level
is pretty rough.

------
kickingvegas
FWIW, with emacs you can use ediff and then type '|' to change to a side-by-
side view.

ediff will also work with SCM (git, svn, etc.) as well.

------
Wildgoose
This is a great tool. I work on Unix (without X) from Windows and so often
have to ftp files about just to use Meld, which is my usual preferred diff
tool.

But I can use icdiff in a PuTTY session with a coloured xterm and get a
sensible and clear diff comparison.

Thanks! I really appreciate this!

~~~
seewhat
Another suggestion, if you haven't ruled it out.

I enjoy using console vimdiff in PuTTY, because my configuration allows quick
navigation without too much thought.

The accumulated time for starting vim can become annoying when iterating over
many files. (I could investigate loading diff pairs into tabs if I was
sufficiently bothered.)

Helpful .vimrc settings:-

Firstly, map some keys to navigate to preceding/successive differences...

    
    
      " Next/ previous diff (analogous to j/k, use the same fingers)
      nmap <F6> ]czt
      nmap <F7> [czt
    

And some helper keys...

    
    
      " Diff update, i.e. repaint the screen when needed
      nmap <F5> :diffupdate<CR>
      
      " Get from Buffer 1/ 2/ 3/ 4
      nmap <F1> :diffget 1<CR>
      nmap <F2> :diffget 2<CR>
      nmap <F3> :diffget 3<CR>
      nmap <F4> :diffget 4<CR>
    

Configure all visible windows when starting via _vimdiff_ or _diffthis_. I
prefer no folding (for added context) and then to navigate with the above
keys.

    
    
      " Apply window-local settings to all diff windows
      au! FilterWritePost * if &diff | set wrap | set foldcolumn=0 | set nofoldenable | endif
    

Finally, set some colors...

    
    
      " Override the diff colours
      highlight DiffAdd term=reverse cterm=NONE ctermbg=darkblue ctermfg=white
      highlight DiffDelete term=reverse cterm=NONE ctermbg=black ctermfg=blue
      highlight DiffChange term=reverse cterm=NONE ctermbg=darkgray ctermfg=white
      highlight DiffText term=reverse cterm=bold ctermbg=brown ctermfg=white
    

Not implemented here is a toggle to ignore whitespace changes (perhaps mapped
to <F8>).

------
cgrinds
It costs a few bucks but BeyondCompare
[http://www.scootersoftware.com/](http://www.scootersoftware.com/) is the best
differ I've used. It's not terminal based, but is supported on Windows, Mac,
and Linux.

------
teddyh
When normal “diff” is not clear enough, I use Emacs and its built-in M-x
ediff-files (or -buffers). It switches to side-by-side view with the “|” key.

------
waxjar
I would suggest highlighting the line that changed as well, with a subtle
background color.

I mostly use GitGutter, a Sublime Text plugin that puts a symbol in the
"gutter" (line numbers column) to indicate which lines changed, where one was
deleted or where one was added. It works only on git repositories, though.

~~~
cbr
Unfortunately "subtle" isn't really an option when working with standard
terminal colors. There are only eight colors, and on most terminals it would
be fair to describe all of them as "garish".

A gutter symbol would be an option, though.

~~~
waxjar
That's a fair point. I did not consider the limited range of colours on most
terminals.

Bold text might also be an option, though it wouldn't immediately distinguish
between added and removed characters.

------
shurcooL
Neat and useful. It reminds me of similar work I've done before at
[https://github.com/shurcooL/Conception-
go/commit/02c5b49187d...](https://github.com/shurcooL/Conception-
go/commit/02c5b49187d2989b6c648ee93f71cef15c6280d4#commitcomment-6927279).

------
ausjke
Had a quick try, looks awesome. it's quicker to do this on command line than
vimdiff sometimes.

I use meld for GUI and noticed it's not 100% accurate, sometimes they can not
tell if two files are different, which is odd.

------
denulu
I've been using `dwdiff -c`, which admittedly doesn't do side-by-side:
[http://linux.die.net/man/1/dwdiff](http://linux.die.net/man/1/dwdiff)

------
yrmt
There's also [http://www.colordiff.org/](http://www.colordiff.org/)

~~~
cbr
colordiff looks like:
[http://www.colordiff.org/screen2.jpg](http://www.colordiff.org/screen2.jpg)

It's just coloring the standard diff output so lines starting with > or + are
yellow and ones starting with < or - are green. This is also what "git diff"
does by default: [http://www.jefftk.com/git-diff-
color-2x.png](http://www.jefftk.com/git-diff-color-2x.png)

icdiff is doing a side-by-side diff, and it's only coloring the changed
sections of lines: [http://www.jefftk.com/icdiff-side-by-
side-2x.png](http://www.jefftk.com/icdiff-side-by-side-2x.png)

~~~
mitchty
Not all that different than what you can achieve with git diff --color-words

Example: [http://i.imgur.com/smubTnH.png](http://i.imgur.com/smubTnH.png)

~~~
cbr
git diff --color-words is good. Here's what that looks like on the same file:
[http://www.jefftk.com/diff-color-words-2x.png](http://www.jefftk.com/diff-
color-words-2x.png)

------
kolev
This is a great little gem! It will replace colordiff in my scripts.

------
cracoucax
Looks great, probably gonna add this to my toolkit.

~~~
cracoucax
ah too bad it's a python scrip though, a binary of some sort would have been
great. I'm growing wary of python version galore.

~~~
cbr
This one works in both python2 and python3.

