Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

`diff --color=auto` is nice, but `vimdiff` is superior


sort by: page size:

Maybe my use-cases are too basic? I appreciate a good diff gui, but really like vimdiff more than almost all of the ones I've seen. For folders `diff -qr one/ two/` does everything I feel like I need. I love just filtering things with grep instead of trying to figure out however that tool wants to ignore specific changes.

diff -y is side-by-side. As far as I know colordiff does per-line coloring, while icdiff seems to have finer granularity. This dude really should have patched colordiff, though. Or just used emacs.

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

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.

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?

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

I honestly prefer vim fugitive's diff function, as it splits with highlighted lines.

Not for a side-by-side diff, but I just use this for color diffs:

    cdiff() {
      diff -u "$@" \
        | sed 's/^\(@@ .* @@\)$/'$'\e[36m''\1'$'\e[m''/g' \
        | sed 's/^\(-.*\)$/'$'\e[31m''\1'$'\e[m''/g' \
        | sed 's/^\(+.*\)$/'$'\e[32m''\1'$'\e[m''/g' \
        | less -c -R
    }

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

Could you add a preview for diff mode? It always disappoints me how (even the default) themes make vimdiff as hard to read as possible.

Interesting. I use `diff`.

There is also `colordiff` which works both as a standalone diff tool, but also as a colorizer filter for other diff tools. For example:

  diff -u a.txt b.txt | colordiff

You can replace colordiff with vim's less tool (/usr/share/vim/vim74/macros/less.sh ) or vimpager (https://github.com/rkitover/vimpager).

icdiff is also nice to have a side-by-side colored diff (https://github.com/jeffkaufman/icdiff). And of course, you could use meld, vimdiff, kompare etc. with the same bash anonymous pipes indirection.


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 :)


I really like vimdiff, but I belive it doesn't do folder diffs (whereas beyond compare does this well)

colordiff is just a perl script to colorize diff's output. Patching it to add support for the kind of coloring I want to do here would be a lot of work.

As for using emacs, there are many cases when I want a stand-alone diff tool.


diffchecker is great! I have it bookmarked (by which I mean I type `di` and then down arrow), and I use it all the time.

You can still use a dedicated diff tool for these situations if they come up regularly. In my experience they are better than vim anyhow.

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...

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

next

Legal | privacy