Vim – How to Compare Two Files

diff()vim

Is it possible to view two files side-by-side in Vim? If so, how can I set up my editor to do this, and is there a way to diff between the two files within Vim?

I am aware of the :next and :prev commands, but this is not what I'm after. It would really be nice to view the two files in tandem.

Best Answer

Open the side by side view:

Ctrl+w v

Change between them:

Ctrl+w h or l

Checkout the vimdiff command, part of the vim package, if you want a diff-like view:

vimdiff file1.txt file2.txt
Related Question