How can I view multiple git diffs side by side in vim

I’d like to be able to run a command that opens up a git diff in vim, with a tab for each file in the diff set.

So if for example I’ve changed files foo.txt and bar.txt in my working tree and I ran the command I would see vim open with two tabs. The first tab would contain a side-by-side diff between foo.txt in my working tree and foo.txt in the repository, and the second tab would contain a side-by-side diff for bar.txt.

  • Convert raw diff file to colorized html output
  • How to check real git diff before merging from remote branch?
  • Git: How can I find a commit that most closely matches a directory?
  • Including new files in SVN diff
  • Can I make git diff ignore permission changes
  • Show both staged & working tree in git diff?
  • Anyone got any ideas?

  • Git post-receive - how to check if pushed branch is merged with master
  • How can I share a git configuration?
  • Determine if directory is under git control
  • Will a git checkout delete files that shouldn't be there?
  • Can't find git-svn on Mac OS X Leopard after installing via MacPorts
  • How to exclude file only from root folder in Git
  • 4 Solutions collect form web for “How can I view multiple git diffs side by side in vim”

    The way I would do this (though it isn’t a single command)

    1. Open files with changes in new vim tabs:

      vim -p $(git diff –name-only)

    2. For every buffer get the diff to your current HEAD with the vcscommand vim plugin


    This gives a nice view of the difference, though not in patch form.

    For anything else I would stick to git diff.


    Like Dave writes below, steps 1 and 2 can be combined by using

    vim -p $(git diff --name-only) -c "tabdo VCSVimDiff"

    Adapted Benjamin Bannier + Dave Kirby’s answer above for fugitive users.

    Because I use fugitive.vim, I adapted the above for my most frequent use case, looking at the diff between the last 2 commits:

    vim -p $(git diff --name-only HEAD~1 HEAD) -c "tabdo :Gdiff HEAD~1"

    Loading all the changes into tabs is so much better than going through them sequentially with git difftool.

    Although it doesn’t do exactly what you want, git difftool is probably your best bet. The out of the box behavior of ‘git difftool –tool=vimdiff –no-prompt HEAD’ is to launch vimdiff sequentially for each file in the working dir with changes.

    This simple plugin has worked for me: TabMultiDiff. It basically creates a diff tab for each pair of files passed to vim. The tab is named after the second file in each pair.

    Note it is not plugin manager compatible, so you need to manually install it by copying tab-multi-diff.vim to .vim/plugin.

    Here is a screenshot of comparing two pairs of simple files (aaa/aab and aac/aad). Note that I also use vim-scripts/diffchar.vim which is why individual characters are highlighted.
    enter image description here

    Git Baby is a git and github fan, let's start git clone.