How do I get a vimdiff view of the effects of patching a file?

1 Answer 1



vim <file> +"vertical diffpatch <patch-file>"

Note the warning from :help inside this this script I call vimdiffpatch:


if [[ $# -ne 2 ]]; then
  echo "Usage: $(basename "$0") <base-file> <patch-file>" 2>&1
echo "From ':help diffpatch':"
echo "Note that {patchfile} should only contain a diff for one file,"
echo "the current file.  If {patchfile} contains diffs for other"
echo "files as well, the results are unpredictable.  Vim changes"
echo "directory to /tmp to avoid files in the current directory"
echo "accidentally being patched.  But it may still result in"
echo "various ".rej" files to be created.  And when absolute path"
echo "names are present these files may get patched anyway."

  exit 1

vim "$1" +"vertical diffpatch $2"

For bonus points, highlight the exact differences, based on characters and words.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.