≡ Menu

Visual File Diff with Vimdiff – It Does Make a Difference!

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)

Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • juhan June 1, 2010, 1:08 am

    Until today I used “meld”, now is time to try “vimdiff”

  • Athul June 1, 2010, 2:07 am

    Good one . Now only came to know about this utility.

  • RAGHU SUBRAMANIAM June 1, 2010, 2:37 am

    really cool. I just remember the time I had spend on diff and heave a sigh of relief.Wish I knew it before.

  • BalaC June 1, 2010, 3:11 am

    So any way to copy the difference from one file to other file using vimdiff utility. I have to manually copy and paste.

  • irfan June 1, 2010, 12:04 pm

    awesome, i m really happy after finding this.

  • jarav June 3, 2010, 3:22 am

    Short and sweet.

  • Felix Frank June 14, 2010, 5:43 am

    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:
    :set diffopt=filler,iwhite

    Also see
    :help diffopt

  • rod June 29, 2010, 5:03 pm

    This website is great because of such useful tips like this one.
    Thanks for telling us about vimdiff.
    Please, keep up posting.

  • Vivek August 26, 2012, 8:49 pm

    how about “comms”?

  • Anonymous March 29, 2017, 12:40 am

    very usefull!