The technique involves using your mind to essentially trick itself and your body by replacing a habit you want to lose with one you want to gain. Say you want to quit smoking. Many smokers automatically light up after finishing a cup of coffee or when they get in the car, saying it relaxes them. What if instead of lighting up that expensive tobacco, the smoker decides to meditate or just count their breaths in a form of mindfulness. Simpler yet, the smoker can chew gum instead of lighting up. It may take a few days to have the new habit settle in, but it does work.
The other thing to remember is that just because you go back to your old habit for a day or so, does not mean you have failed. Just get back into the new habit and forget about that failure. There is a famous quote from the 19th century Transcendentalist. Ralph Waldo Emerson, that I keep on my refrigerator and on my iPhone that is particularly relevant. Let me know what you think: