Diff Files in Neovim

Here's a method for diffing two files side by side in neovim.

Git has its own diff, and there are many 3rd-party utilities. But sometimes you want to diff two files that are not under version control. You can use the diff command, but the output is difficult to read.

Neovim has its own diff mode (see :help diff-mode). In it, you can see the different files (from 2 to 8 files) side by side. The buffers are bound together, syncing the scrolling.

To enter diff mode from the terminal, start nvim with the -d option:

nvim -d file1 file2

screenshot of nvim diff