Side-by-side view in Vim of svn-diff for entire di

2019-08-12 16:37发布

I have a MacVim setup on my OSX machine so that the default Vim application (ie: /usr/bin/vim) is actually a symbolic link to the command-line version of Vim that ships with MacVim (ie: /Applications/MacVim.app/MacOS/vim), as it provides some key benefits over the stock Vim that ships with OSX10.6.

I periodically need to prepare a diff between a set of files, and export it into a colorful side-by-side-view HTML file. This is commonly achieved via:

vim -d file1 file2
(Within Vim): toHTML

The problem with this is that I have to manually check out the HEAD revision and a specific revision of the two sets of files, and do this operation for each pair of files. This is very time consuming.

Is it possible to have the results of svn diff command piped into Vim so I can have a colorful side-by-side-view diff for an entire directory (ie: the PWD), as opposed to just the unified diff view?

I have found several Vim scripts and bash scripts that attempt to achieve this, but there are two key problems:

  1. I wish to explicitly call vim -d as the diff tool, and not vimdiff, as the MacVim application does not appear to ship with vimdiff, so I would be using the wrong version of Vim when launching the application

  2. I wish to have multi-file diffs generated against an entire directory recursively, as opposed to just one or two files at a time.

If this is not feasible, I could likely create a bash script that more-or-less achieves this, but I'd like to avoid putting together a hacked/unreliable script if there is a more effective means of doing this.

Thank you.

3条回答
Bombasti
2楼-- · 2019-08-12 17:13

vimdiff is merely an alternate name for vim. The binary checks to see how it's launched and determines its behavior accordingly. (That's why there isn't a different file for gvim and vim also.)

On my Mac OS and Linux machines I created a ~/bin directory, and then inside it created soft-links from the various names to my macvim binary. I put ~/bin very early in my path.

I'm not at work where I could check to make sure, but I think you can change the default SVN diff to point to vimdiff in ~/.subversion/config. Look for the diff-cmd section. https://stackoverflow.com/a/9604604/128421 might give you some useful information too.

查看更多
Root(大扎)
3楼-- · 2019-08-12 17:23

I have since resolved this fully in another, more recent post of mine. Posting a backtrack URL to it for future readers:

VIM - Passing colon-commands list via command-line

查看更多
时光不老,我们不散
4楼-- · 2019-08-12 17:30

You can try my aurum plugin, it ships with :AuVimDiff command which is as well capable of viewing all changes in a multiple tabs with vimdiff split:

AuVimDiff full HEAD 300

and get diffs between two revisions without you having to checkout them manually:

AuVimDiff file file1 HEAD 300

(file file1 part is optional, it will open diffsplit with current file if omitted. All revisions are also optional, for subversion specifying one revision is diffing it with file in the working directory and specifying no revisions is like svn diff: between BASE and working directory.)

300 here is just an example revision.

查看更多
登录 后发表回答