vimdiff shows differences between two or more of same files. Is it possible to see differences of two pairs of files. For eg, when viewing differenes in .H
files and .C
file, it will be convenient to go back and forth to see the differences. One way is to open old.C
new.C
old.H
new.H
using vim and then splitting them and running :diffthis
in each buffer. Is there a better way?
Asked
Active
Viewed 474 times
5

balki
- 26,394
- 30
- 105
- 151
-
I've only used :diffthis with 2 files. Don't know a better way. – sashang Oct 23 '12 at 07:20
-
There are good solutions in the question and in Ingo Karkat's answer, but I just have to mention a less sophisticated alternative: open vim in two windows, using vimdiff separately in each for the two pairs of files. If you're using vim in a terminal, you'll need two terminal windows. There are also graphical versions of vim that can open different windows directly, but that might depend on your operating system and whether you've installed a graphical version of vim. (Ditto for neovim.) – Mars Mar 13 '23 at 22:48
1 Answers
7
When you use vimdiff
, it'll diff all passed files together. To get pairwise diffing, pass and arrange the pairs in separate tab pages:
vim -c "edit old.C" -c "diffsplit new.C" -c "tabedit old.H" -c "diffsplit new.H"
If you do this often, you can write an alias / script wrapper for it.

Ingo Karkat
- 167,457
- 16
- 250
- 324