Comparing two files

Using vimdiff to compare two files is fairly simple. Let's look at two files in animal_farm/ : animals/cat.py and animals/dog.py. We'd like to know what's different between the two.

Open the files with vimdiff:

$ vimdiff animals/cat.py animals/dog.py

You will be greeted to the following screen (how colorful the screen is will depend on your colorscheme):

You can see animals/cat.py open in a split on the left and animals/dog.py in a split on the right. Different lines are highlighted ...

Get Mastering Vim now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.