Have you had a look at the manual, http://www.macromates.com/textmate/manual/ ? In particular chapters 12, 13 and 14 should be of interest to you. Jeroen.