3

Is there a diff tool which can highlight single character edits as such, and not just show the old and new version of the whole line (i.e. the kind of diff StackExchange shows you for edits to a post)?

I'd prefer one I could use on the Linux command line as diff in git.

arney
  • 795
  • 7
  • 20

1 Answers1

7

You can try, from git diff:

git diff --color-words=.

Which is equivalent to --word-diff=color plus (if a regex was specified) --word-diff-regex=<regex>.

That would transform this git diff:

https://d262ilb51hltx0.cloudfront.net/max/800/1*DAIIfQVu0nLzgb7xw7mLjQ.png

into this one:

https://d262ilb51hltx0.cloudfront.net/max/800/1*Mb16aJnq46sv87QcYwZu-Q.png

Images are from the section "Produce more useful diffs" of the article "30 Git CLI options you should know about" written in Sept. 2014 by Christophe Porteneuve.

theonlygusti
  • 11,032
  • 11
  • 64
  • 119
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250