3

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

3

Use:

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

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

#!/bin/bash

if [[ $# -ne 2 ]]; then
  echo "Usage: $(basename "$0") <base-file> <patch-file>" 2>&1
echo
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
fi

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

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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