A blog by Rob J Hyndman 

Twitter Gplus RSS

Tracking changes in text files

Published on 20 August 2008

A com­mon issue that arises with text files (e.g., R code) is to iden­tify changes that have been made between ver­sions. I usu­ally num­ber my R files as file1.R, file2.R, etc. (with “file” replaced by some­thing more meaningful),with the num­ber indi­cat­ing the ver­sion of the file. Ver­sion num­bers change when­ever I send the file to some­one else to mod­ify, or when­ever I make major changes myself.

I often need to know what changes have been made between suc­ces­sive ver­sions. The best solu­tion I’ve found is Com­pare It!. All I need to do is high­light the two files in Win­dows Explorer, right click and choose “Com­pare 2 files”. Then a screen show­ing the dif­fer­ences appears. An exam­ple is given below.

The bar on the left shows the parts of the file that have been changed. White back­ground denotes unchanged lines.

The soft­ware enables me to:

  • See all dele­tions, addi­tions & changes highlighted.
  • Choose to over-​​ride any changes that are not wanted.
  • Edit either file onscreen and refresh the high­lighted differences.

I fre­quently use this soft­ware for R files and other text file. I some­times use it for LaTeX files, but here there is often a prob­lem with changes caus­ing sub­se­quent lines to re-​​wrap, thus pro­duc­ing appar­ent changes that have no effect on the final result.

For LaTeX files, there is a bet­ter solu­tion which I will dis­cuss in the next post.


Related Posts:


 
Tags:
No Comments  comments