How to diff two files easily in vim

As the saying goes, if you do something for the first time, do it. If you do it for the second time, copy-paste the process. If you do it for the third time, find a way how to save the process somewhere so you don’t need to find and copy-paste it. And I need to diff some files again…

So, how to do it in my favorite editor vim? Easily.

  1. Open the first file.
  2. Open the second file in the same window (so you have the files side by side). This can be done with theCtrl + w vcommand.
  3. Then, in the first window type the command:windo :diffthis

Here you go.

Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: