How can I use vimdiff to view the differences described in a diff file?
-
Make a copy of the original file, apply the diff and then
vimdiff original_file patched_fileYou could also look at vim.org scripts which have been written to deal with svn diff output. If you are generating your diff from a version control system then take a look at the vcscommand.vim : CVS/SVN/SVK/git integration plugin.
From Ken -
Instead of using
/usr/bin/vimdiffcommand, try this:$ vim file :vertical diffpatch path/to/diff
(
:vert diffpafor short.)
This is equivalent to callingvimdiffon the original file and the subsequently patched file, butvimcallspatchon a temporary file for you.Edit
If you want
vim's diff-mode to be entered automatically, use this:$ vim file +'vert diffpa path/to/diff'
where
+commandasksvimto execute "command". (+123jumps to line 123,+/abcjumps to the first match for "abc", it's all documented.)Regarding Ken's query: if the diff file includes hunks applying to files other than the file you're currently editing, no worries;
vimcalls thepatchexecutable underneath, which will ask for the locations of these mysteriously missing files, and you can tellpatchto just skip those hunks.Ken : nice! But you should maybe warn about the risk of side-effects if the file contains diffs for other files?From ephemient -
Coming from the other direction. I wrote a Vim plugin that shows the changes that have been made to a file since the last save in either vimdiff or unified diff format.
Get it here: diffchanges.vim
From Jeremy Cantrell
0 comments:
Post a Comment