created December 18, 2002 · complexity basic · author Jens Finkhäuser · version 6.0
I like using vim's diff mode for comparing different revisions of source code files. usually older versions do not live in the directory structure with the current versions, but in a cvs repository. the command below, CVSdiff, can compare the current file to any given revision number in the cvs repository. please note that in case a revision number does not exist, empty files will be displayed, as the below script does not do any error checking (yep, i'm lazy, and this works for me). a vertical split is performed on the current file and its given previous revision.
command -nargs=1 CVSdiff silent call CVSdiff("%", "<args>") function! CVSdiff(filename, cvsversion) " append a:filename to keep extension and therefore highlighting mode let patchname = tempname() . a:filename let tempname = tempname() . a:filename let newname = tempname() . a:filename execute "!cvs diff -a -r " . a:cvsversion . " " . a:filename . " > " . patch execute "!cp " . a:filename . " " . tempname execute "!patch -R -o " . newname . " " . tempname . " < " . patchname execute "vertical diffsplit " . newname call delete(patchname) call delete(tempname) call delete(newname) endfunction
Comments[]
See script#58. It is very useful.
I use script#90 (cvscommand.vim).
There is a little error of this tip, and I believe it is just a typo.
line 7:
execute "!cvs diff -a -r " . a:cvsversion . " " . a:filename . " > " . patch
'patch' should be corrected to 'patchname'.
I've written a shellscript "cvsvimdiff", it is available here: http://www.bononia.it/~zack/myprograms.en.html Direct link to the script: http://www.bononia.it/~zack/stuff/cvsvimdiff
It can be used as you use "cvs diff", but it spawns a vimdiff process to examine the differences.
Same idea of this tip, but I find it more handy since you usually need to review diffs during a shell session, just after "cvs update".