If you have a habit you want to break, the key is figuring out the cues that tell your brain to start engaging in whatever the behavior is. According to Charles Duhigg in a NY Times article, "experiments have shown that most cues fit into one of five categories: location, time, emotional state, other people or the immediately preceding action.
When the urge strikes to engage in whatever bad habit you are in, ask yourself:
Where am I?
What time is it?
How do I feel?
Who else is around or what just happened?
Once you have a few data points recorded, you may see patterns. Break the pattern(s), and you are more likely to succeed in breaking the habit. Always smoke after an argument? Try going for a walk. Always eat tortilla chips while watching a football game? Watch the game at a different location -- perhaps a room in which you never eat, or with friends who aren't into salty snacks.