MN 20 is the twentieth sutta (teaching) in the middle length teachings of the Buddha. It describes a five step process for training the mind that will eventually result in thinking what you want to think, and not thinking what you don’t want to think. I have been doing it for 2.5-3 years and I am seeing progress in that direction. Flash cards pdf file link at bottom.
Step 1: Drive out the problem thought with a known wholesome thought like a carpenter would drive out a large peg with a thinner one. Wholesome thoughts for most religions are one word mantras of either “God” or “Allah” “Buddha” “non-killing” Or “may all beings be nobly and rightly happy” or “non-oppression” you get the idea.
When you are successful, you will feel the mind settle and still comfortably. If not, on to step 2.
Step 2: Regard the thought as a danger to you, truly it leads to your suffering. Then feel gently horrified and repulsed and dedicate that energy to future restraint. The horrified and repulsed can be overdone and then you burn out and it takes a long time to heal. be on your guard against overdoing it.
As before, When you are successful, you will feel the mind settle and still comfortably. If not, on to step 3
Step 3: Ignore the problem thought. This gives the first two inputs more room to work their magic. I like to imagine that my attention is one of those sticky hand toys and I peel it off of the problem thought and place it on the wholesome thought from step 1.
Step 4: Still the thought formation as regards the problem thought. The Buddha uses a simile of a man who is running thinking why don’t I walk then walking… then thinking why don’t I stand… why don’t I sit… why don’t I lie down.
If it works, You’ll know because the mind will settle inwardly, still and calm if not, step 5.
Step 5: Clench your teeth, push your tongue against the roof of your mouth and hit, bend, and crush the problem thought into submission. I must advise against using edged or pointed stabby weapons of the mind. It is difficult to stop using them, and they wind up being used against you.
When you are successful, you will feel the mind settle and still comfortably. If not, the Buddha did not say what to do, I’ve been assuming that I must have messed up one of the earlier steps and starting over at step one.