Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

Efficiently manage the differences between two files using vim.

Project description

Author: Ken Kundert
Version: 2.5.0

Opens two files in vimdiff and provides single-stroke key mappings to make moving differences between two files efficient. Up to two additional files may be opened at the same time, but these are generally used for reference purposes.


vdiff [options] <file1> <file2> [<file3> [<file4>]]


-v, --vim Use vim (rather than default).
-g, --gvim Use gvim (rather than default).
-f, --force Edit the files even if they are the same.
-q, --quiet Issue only error messages.
-h, --help Print this helpful message.

Relevant Key Mappings

Ctrl-j Move down to next difference
Ctrl-k Move up to previous difference
Ctrl-o Obtain difference
Ctrl-p Push difference
{ Update file1 to match file2
} Update file2 to match file1
S Save any changes in all files and quit
Q Quit without saving any file
= Make all panes the same size and rotate between them
+ Update differences

When comparing 3 or 4 files, you must prepend the buffer number to the push or obtain command. The buffers are numbered from the left to the right starting with 1. For example, to obtain the difference from buffer 3, move to that difference and type ‘3 Ctrl-o’.


Defaults will be read from ~/.config/vdiff/config if it exists. This is a Python file that is evaluated to determine the value of three variables: vimdiff, gvimdiff, and gui. The first two are the strings used to invoke vimdiff and gvimdiff. The third is a boolean that indicates which should be the default. If gui is true, gvimdiff is used by default, otherwise vimdiff is the default. An example file might contain:

vimdiff = 'gvimdiff -v'
gvimdiff = 'gvimdiff -f'
gui = True

These values also happen to be the default defaults.

As a Package

You can also use vdiff in your own Python programs. To do so, you would do something like the following:

from inform import display, Error
from vdiff import Vdiff

vdiff = Vdiff(lfile, rfile)

    if vdiff.differ():
        display('%s and %s are the same.' % (lfile, rfile))
except KeyboardInterrupt:
except Error as err:

Using Vdiff with Mercurial

To use Vdiff with Mercurial, merge the following entries into your ~/.hgrc file:

merge = vdiff

extdiff =

cmd.vdiff = vdiff
opts.vimdiff = -g

These will result in Vdiff being used whenever a merge conflict occurs. It also allows you to use ‘hg vdiff’ to view differences between versions.


Runs only on Unix systems. Requires Python 3.5 or later. Install by running ‘./install’ or ‘pip3 install vdiff’.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for vdiff, version 2.5.0
Filename, size File type Python version Upload date Hashes
Filename, size vdiff-2.5.0.tar.gz (6.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page