Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using vim as git difftool

I've configured Vim as git difftool in .gitconfig

[diff]
    tool = vimdiff

If there are changes in N files, i have to close vim (:qa) to see the next diff.

How do i navigate to the next/previous diff without quitting vim?

like image 885
Sathish Avatar asked Feb 05 '13 12:02

Sathish


People also ask

How do I use git Difftool?

Use the diff tool specified by <tool>. Valid values include emerge, kompare, meld, and vimdiff. Run git difftool --tool-help for the list of valid <tool> settings. If a diff tool is not specified, git difftool will use the configuration variable diff.

What is Vimdiff?

Description. Vimdiff starts Vim on two (or three or four) files. Each file gets its own window. The differences between the files are highlighted. This is a nice way to inspect changes and to move changes from one version to another version of the same file.


1 Answers

There is no way to tell vimdiff to go to the next file, because git difftool invocates vimdiff for each diff file.

So when you end vimdiff with qa, git diff executes vimdiff again with the next file. From vimdiff's perspective there is no next diff file.

You can suppress the prompt for launching vimdiff, which makes it less annoying:

git config --global difftool.prompt false

But, as you already found out yourself, the vim plugin vim-fugitive is the way to go. This excellent plugin offers various commands for diffing and merging.

like image 100
cutemachine Avatar answered Oct 18 '22 00:10

cutemachine