wdiff: Word-Level Diff Between Files
wdiff compares two files word by word and marks inserted and deleted words inline rather than replacing whole lines.
For prose, docs, or files with very long lines, line diffs are unreadable. wdiff shows exactly which words changed, which is far clearer for text review.
What it does
wdiff runs diff under the hood but reports differences at word granularity. Deleted words are wrapped in [- -] and inserted words in {+ +}, so a one-word edit shows as a one-word change instead of a whole rewritten line. Exit status follows diff (0 same, 1 differ).
Common usage
wdiff old.md new.md
# terse: only show the changed words
wdiff -3 old.md new.md
# statistics on words added/deleted
wdiff -s old.md new.mdOptions
| Flag | What it does |
|---|---|
| -3 | Show only lines from the third (changed) group |
| -s | Print statistics about the comparison |
| -i | Ignore case |
| -w / -x | Set the string that begins/ends a deletion |
| -y / -z | Set the string that begins/ends an insertion |
In CI
Use wdiff to check documentation or generated text where line-level diffs produce noise. Pipe it into colordiff-style rendering or set custom -y/-z markers so the CI log clearly shows word-level edits in changelogs or generated docs.
Common errors in CI
"wdiff: command not found" means the wdiff package is missing. Garbled markers in a log usually mean a downstream tool re-wrapped the [- -] / {+ +} sequences; set explicit -w/-x/-y/-z delimiters. wdiff loads both files into memory, so it can be slow or memory-hungry on very large inputs; prefer diff there.