14.06.2014 Views

vim 101 hacks

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Buyer: xiujuan lu (luxiujuan@gmail.com)<br />

Transaction ID: 85W16630AD8515549<br />

Vim <strong>101</strong> Hacks<br />

www.thegeekstuff.com<br />

Hack 79. Review the Differences between Files using<br />

Vimdiff<br />

Similar to the Unix diff command, <strong>vim</strong>diff is used to show the difference<br />

between files. Unlike the Unix diff command, <strong>vim</strong>diff is more colorful and<br />

user-friendly.<br />

Unix diff command text output:<br />

$ diff employee.txt new-employee.txt<br />

1c1<br />

< 100 Jason Smith Developer<br />

---<br />

> 100 Jason Smith Senior Developer<br />

4a5,7<br />

> 500 King James Manager<br />

> 600 Raj Patel Team Lead<br />

> 700 Emily Jacob HR<br />

Vimdiff visual output:<br />

In the following example, it is very easy to visually see what was changed and<br />

added between the two files.<br />

$ <strong>vim</strong>diff employee.txt new-employee.txt<br />

Fig: <strong>vim</strong>diff showing visual diff<br />

117

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!