Five tricks to avoid unwholesome kamma
Vitakka Saṇṭhāna Sutta gives the following 5:


Replace the unwholesome thoughts with wholesome thoughts
Examine the drawback of unwholesome thoughts
One sould forget unwholesome thoughts
One should try to still the source of unwholesome thoughts
Subdue the unwholesome thoughts