The diff command output can get little confusing to read when you diff two files that has lot of differences. Wouldn’t it be nice to view the file differences visually? vimdiff utility gives a better visual feeling of differences between files as explained in this article.
1. Difference in whole line – Blue Color and Hyphens
If line X is available in one file and not available in another file, then file containing the line will be highlighted with blue color, and the file without that line will be displayed with hypens and in light green color as shown below.
Fig: Whole line difference in Vimdiff (click on image to enlarge)
2. Difference in partial line – Red Color
If only a part of the line is different between the two files, the line will be highlighted in rose color, and the partial difference will be highlighted with red color as shown below.
Fig: Partial line difference in Vimdiff (click on the image to enlarge)
3. Lines are same
If some lines of the two files are same, it will appear as it is ( i.e without any highlight ).
If many lines of the two files are same, it will be folded automatically, and shown as +N lines as shown below. To expand the fold press SPACE.
Fig: Multiple lines without difference are folded in Vimdiff (click on the image to enlarge)
Comments on this entry are closed.
Until today I used “meld”, now is time to try “vimdiff”
Good one . Now only came to know about this utility.
really cool. I just remember the time I had spend on diff and heave a sigh of relief.Wish I knew it before.
So any way to copy the difference from one file to other file using vimdiff utility. I have to manually copy and paste.
awesome, i m really happy after finding this.
Short and sweet.
The following vim commands are helpful for editing in diff mode:
“do” or :diffget –> make diff under curser equal to other buffer
“dp” or :diffput –> make other buffer equal to diff under cursor
:diffupdate –> refresh if vim was confused by either of above operations
You may want to try the following setting:
This website is great because of such useful tips like this one.
Thanks for telling us about vimdiff.
Please, keep up posting.
how about “comms”?