Thursday, August 23, 2007

file diff using vim

starting diff mode

vimdiff file1 file2 or vim -d file1 file2


while already in vim you can start diff mode in three ways.

:diffsplit {filename} - open a new window on the file {filename}
:diffthis - make the current window part of the diff windows
:diffpatch {patchfile} - use the current buffer, patch it with the diff found in {patchfile} and open a bufer on the result



jumping to diffs

[c - jump backwards to the previous start of a change
]c - jump forwards to the next start of a change



diff copying

:[range]diffg[et] - modify the current buffer to undo difference with another buffer
:[range]diffpu[t] - modify another buffer to undo difference with the current buffer
do - same as ":diffget" without argument or range. the "o" stands for "obtain"
dp - same as ":diffput" without the argument or range

when no [range] is given, the diff at the cursor position or just above it is affectes.

No comments: