2021-10-11 Highlighting word differences when diffing

I have a short tip for today. Sometimes it is useful to diff two files (in terminal), highlighting the differences on the level of words. Apparently, GNU diff cannot do that – but Git can. Did you know that you can say git diff –word-diff=color <file1> <file2> even outside any Git repo? (You can also use plain instead of color, or just say –word-diff then, since plain is the default, and use --word-diff-regex to define what a “word” is.)

You’re welcome!

CategoryEnglish, CategoryBlog, CategoryGit