TL;DR
The 8 most useful wdiff
invocations. Copy-pasteable. If you remember nothing else,
remember the first one.
The essentials
# Word diff: show which words changed between two files
$ wdiff old.txt new.txt
the [-quick-]{+slow+} brown fox
jumps over the [-lazy-]{+sleepy+} dog
Read one file from stdin (use '-' or omit the second arg)
$ echo 'the fast red fox' | wdiff - - <<< 'the slow red fox'
the [-fast-]{+slow+} red fox
Suppress common text (show only the changes)
$ wdiff -3 old.txt new.txt
Statistics to stderr (word counts + change breakdown)
$ wdiff -s old.txt new.txt
old.txt: 7 words 6 86% common 1 14% deleted 0 0% changed
new.txt: 7 words 6 86% common 1 14% inserted 0 0% changed
Re-format a unified diff at the word level (read from stdin)
$ git diff | wdiff -d
Colour, terminals, and CI
Force colour markers (e.g. for CI logs)
$ wdiff --color=always old.txt new.txt | less -R
Auto-pager (only when stdout is a tty)
$ wdiff -a old.txt new.txt
Quiet mode: exit 0/1 only, no output (for shell scripts)
$ wdiff -q old.txt new.txt && echo same || echo different
Advanced
Custom markers (e.g. ANSI bold instead of the default [- / {+ )
$ wdiff -w $'\033[1;31m' -x $'\033[0m' \
-y $'\033[1;32m' -z $'\033[0m' \
old.txt new.txt
Compare two files case-insensitively
$ wdiff -i OldFile.TXT newfile.txt
Show only the deleted words (e.g. for "what was removed?" reports)
$ wdiff -1 old.txt new.txt
When NOT to use wdiff
wdiff uses isspace() to detect
word boundaries. On CJK text without spaces (Chinese /
Japanese / Korean), the entire CJK line is treated as one
"word" and the diff shows it as a single delete+add. For
CJK-aware word diff, use
dwdiff
instead — it bundles libicu 78.3 for proper
Unicode segmentation.