Resolving conflicts with vimdiff
Often, during development, you’ll find yourself needing to compare some files—be it comparing different output or versions of a file, or dealing with merge conflicts as multiple developers collaborate on a single file. Vim provides vimdiff
, a standalone binary that excels at file comparison operations.
Comparing two files
Using vimdiff
to compare two files is fairly simple. Let’s look at two files in spam/kitchen/
: kitchen/bacon.py
and kitchen/egg.py
. We’d like to know what’s different between the two.
Code location
The files from this example are available from https://github.com/PacktPublishing/Mastering-Vim-Second-Edition/tree/main/Chapter05/spam.
Open the files with vimdiff
:
$ vimdiff kitchen/bacon.py kitchen/egg.py
You will be greeted by the following screen (how colorful the screen is will depend on your colorscheme
):
Figure 5.13 – The vimdiff
window shows...