This is actually great advice for any bad habit you're trying to break. In general, just thinking "Stop doing this thing" (or "do less of this thing"), doesn't really work. It's usually more effective to find something else that you do enjoy (and is better for you), and try to do more of that thing and have it "crowd out" your bad habit.
When it comes to eating, there is a nutritionist with a pretty sizable online following (Kylie Sakaida), and I love one of her mantras of "add, don't subtract". That is, don't think of abstaining from foods you like that might be unhealthy, but instead try to add more healthy things to that food to make it a balanced meal. For example, she gives the example of wanting a frozen waffle for breakfast. Instead of thinking "No, I can't have this frozen waffle", she instead makes a spread using Greek yogurt to add protein, then adds fresh fruit and nuts for more nutrients, fiber and healthy fats, so what started as an 'empty carbs' meal is turned into a pretty balanced, filling breakfast.