Reputation: 127428
scmdiff marks the differences between the checked in version of a file and the file that's being edited. It marks it by coloring the changed lines. Is there any way to view the changes using a vimdiff
-style split instead of just coloring the changed lines?
For instance, if abc
is a file under version control, then I can use the following to display the current version of abc
on one side and the latest version on the other side:
tkdiff abc
I can also do:
tkdiff -r1 -r5 abc
to show the differences between versions 1 and 5. Finally, I can do:
tkdiff -r1 abc
to see the difference between the current version and version 1.
This is the sort of diff I'd like to see between two versions of a file, only using Vim. Can it be done? I'm working under Linux and I use Bitkeeper for version control.
Upvotes: 5
Views: 3215
Reputation: 4029
I use the vcscommand plugin for interacting with a VCS.
From the description:
VIM 7 plugin useful for manipulating files controlled by CVS, SVN, SVK and git within VIM, including committing changes and performing diffs using the vimdiff system.
In particular :VCSVimDiff
will split the current window and show a "vimdiff" against the latest version in the repo. You can also specify one revision number to compare the current buffer to (i.e. :VCSVimDiff -2
), or two revision numbers to diff to each other. Here is the relevant section from the docs:
:VCSVimDiff
Uses vimdiff to display differences between versions of the current file.
If no revision is specified, the most recent version of the file on the current branch is used. With one argument, that argument is used as the revision as above. With two arguments, the differences between the two revisions is displayed using vimdiff.
With either zero or one argument, the original buffer is used to perform the vimdiff. When the scratch buffer is closed, the original buffer will be returned to normal mode.
Once vimdiff mode is started using the above methods, additional vimdiff buffers may be added by passing a single version argument to the command. There may be up to 4 vimdiff buffers total.
Using the 2-argument form of the command resets the vimdiff to only those 2 versions. Additionally, invoking the command on a different file will close the previous vimdiff buffers.
Upvotes: 8
Reputation: 8745
VCSCommand plugin is really helpful in this case and it woks seamlessly with SVN,CVS and other repositories also. :VCSVimDiff
applies vimdiff between the file loaded in buffer and the copy in repository.
Upvotes: 2
Reputation: 7447
For ClearCase VCS there exists a plug-in which also does what you want.
Upvotes: 0
Reputation: 51593
I'm a happy user of bazaar's vimdiff plugin. For git, there's gitvimdiff (and several other solution can be used). Mercurial can do this as well.
Upvotes: 1
Reputation: 745
I use vimdiff with subversion the following way:
When I want to see differences in vimdiff for a specific file or a group of files I do:
svn diff [files] --diff-cmd svd
Here the --diff-cmd instructs subversion to use the command "svd" instead of its default diff behavior. svd is the following shell script:
#!/bin/bash
shift 5; /usr/bin/vimdiff -f "$@"
You did not mention your OS, the above will work for Linux and OS X for sure.
Upvotes: 9