Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Configure Git To Use Vimdiff

Run the following commands if you wish to set vimdiff as your diff tool:

git config --global diff.tool vimdiff
git config --global merge.tool vimdiff

Alternatively, add the following to your $HOME/.gitconfig

[diff]
    tool = vimdiff
[merge]
    tool = vimdiff

Now you can show differences by running:

git difftool

Allow Editing

By default, vimdiff will open the files in readonly mode so that you can't make any changes. You can enable editing inside the editor by running the following:

:set noro

To make this the default, edit your $HOME/.vimrc config, add this (you may need to create it):

" Default to not read-only in vimdiff
set noro

Referemces

Last updated: 9th May 2020
First published: 7th April 2020

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch