The Power of Habit says it’s impossible to remove a habit. You will need to combat it with willpower. This may become habitual itself. But when you suddenly have a really bad period, chances are big you will fall back into the old habit.

The book goes on to say that it is possible to replace a habit. You need to keep the trigger and reward the same, but replace the routine.

You could replace a smoking habit by one below, depending on your trigger and reward at the time.

Trigger Routine Reward Context
feeling stressed grab jacketinvite colleaguego outsidelight a cigarette feeling connected /relaxed feeling Smoking
feeling stressed grab a jacketinvite colleaguego outsiderun feeling connected /relaxed feeling Running
feeling stressed find a quiet roommeditate relaxed feeling Meditation

Same with drinking a lot of coffee.

Trigger Routine Reward Context
feeling tired walk to kitchenmake coffeepour a cupadd lots of sugardrink coffee caffeine /sugar /hot beverage /5 min meditation Coffee
feeling tired walk to kichengrab appleeat apple caffeine /sugar /hot beverage /5 min meditation Fruit
feeling tired walk to kichenmake teaadd lots of sugardrink tea caffeine /sugar /hot beverage /5 min meditation Herbal tea

The most difficult part here is finding out exactly which trigger and which rewards drives the behaviour. You can have a desire for coffee because: you’re tired -> caffeine you need a break -> 5 min break you have low blood sugar -> sugar your stomach is upset -> hot beverage

So once you know which trigger and which reward are driving the habit (in this case) you can replace the routine, but keeping the trigger and reward the same.

(src: Book: The Power of Habit)