Thursday, March 13, 2008

Reading STDIN

This is pretty basic, but it's also really useful. Vim can read standard input via a pipe at the end of any common command chain. I use Vim in conjunction with diff all the time to analyze the difference between two or more source files.

diff -u | vim -

Compare the difference of two source trees before submitting your patch:

diff -Naur oldtree newtree | vim -


Anonymous said...

why not use vimdiff?

Travis Whitton said...

AFAIK, vimdiff doesn't allow you to compare by directory.

Anonymous said...

thanks a lot. its very useful

Anonymous said...

You can use vim's internal diff program which is real nice!

$ vim -d file_one.txt file_two.txt