Some of you using the vim editor may not know about a tool that comes with vim called vimdiff. Vimdiff is an awesome way to diff files if you are a vim nut. It gives you the power of vim + the power of diff.
How's this different from opening 2 files in vim (with -O option) you ask ? The difference is that vim will highlight the diff for you.
Fire it up by giving the 2 filenames, say
$vimdiff old new
This will bring up a screen like this -
[caption id="" align="aligncenter" width="512"
caption="vimdiff"][/caption]
Now you can move around the 2 parts of the screen with your regular vim commands. For eg. use (Ctrl+w) + right arrow to move to the right half of the screen.
[caption id="" align="aligncenter" width="512" caption="vimdiff with
cursor on right half of screen"][/caption]
You can copy paste as well. Go to the 2nd line in the left half and press the y key twice to copy that line. Use (cntrl + w) + right arrow to move cursor to the 1st line in the right half of the screen. Press p to paste the copied line below the 1st line.
[caption id="" align="aligncenter" width="512" caption="vimdiff with
copy paste"][/caption]
You can go to the first line and delete the two words "a new" by moving the cursor to "a" and hitting d2w key combo.
[caption id="" align="aligncenter" width="512" caption="vimdiff deletes
words"][/caption]
Insert "an old" there by going to insert mode(press i key) and then typing the two words. You'll see that vimdiff does not highlight anything. This means that there is no difference between the two files.
[caption id="" align="aligncenter" width="512" caption="two files with
no difference in vimdiff"][/caption]
Vimdiff is the same as bringing up vim with the -d option. You could do the same things you did above by using
$vim -d old new
[caption id="" align="aligncenter" width="512" caption="vimdiff also
works directly with URLs"][/caption]
If you're a vim/vimdiff ninja and know some more tricks, do post them below :)
Happy hacking...