Yoga Sutras 2.33
Patanjali, explained by Swami Vivekananda
वितर्कबाधने प्रतिपक्षभावनम् ॥
vitarkabādhane pratipakṣabhāvanam
To obstruct thoughts which are inimical to Yoga, contrary thoughts should be brought.
In plain words: When a harmful thought comes up, deliberately think the opposite thought. The teacher gives an example: an angry mother sees her baby, feels love, and the anger fades.
Swami Vivekananda explains
That is the way to practise the virtues that have been stated. For instance, when a big wave of anger has come into the mind, how are we to control that? Just by raising an opposing wave. Think of love. Sometimes a mother is very angry with her husband, and while in that state, the baby comes in, and she kisses the baby; the old wave dies out and a new wave arises, love for the child. That suppresses the other one. Love is opposite to anger. Similarly, when the idea of stealing comes, non-stealing should be thought of; when the idea of receiving gifts comes, replace it by a contrary thought.