compare files and edit simultaneously with vimdiff

November 24th, 2006 mysurface Posted in Developer, vi, vim, vimdiff | Hits: 66870 | 3 Comments »

Refers to How to create patch file using patch and diff, you can actually read the diff file to compare the difference between the files. But what if you wanna compare and edit simultaneously?

Given 2 different files at your hand, you can do that with vimdiff. Let say I wanna compare this two files Tb01/TbApi.cpp and Tb02/TbApi.cpp, I can do this

 vimdiff Tb01/TbApi.cpp Tb02/TbApi.cpp

It nicely put two codes in a split windows, one at left and another at right. And it shows clearly the differences of them with highlights and line spacing. You really have to try it yourself to see how efficient it is.

By shifting from one windows to another, by pressing ctrl + w and press right arrow to move from left to right.

After finish editing,


To close both files and simultaneously write the changes, or


which close both files without save.

3 Responses to “compare files and edit simultaneously with vimdiff”

  1. Use ctrl+ww to switch to next region, I find it more easy than ctrl+w arrow key.

  2. It’s useful for me! Thanks a lot!

  3. It seems like something is missing, no?

Leave a Reply