replace them with good ones. put all measures in place to prevent yourself from taking part in those bad habits. if it's something you do privately, then go in public and stay there. keep yourself busy by eating a bunch of food. try to notice when you do those habits or become more aware of them and try to stop
Define your goals and then commit yourself to achieving them. People who acknowledge that they need to make a change in their life are more likely to achieve that change than those individuals who think that they may, or may not, have a problem.
Don't do it alone. Get help. If you choose to discuss your goals with others, choose people who want you to succeed. Quitting bad habits is hard enough without having to watch the people near you enjoying what you have now deprived yourself of.
Reward yourself! Continue to acknowledge and reward yourself for the "baby-steps" you take in kicking a bad habit. Let the people around you reward your success and cheer you on the next step.
If you're talking about drugs, then we are on the same boat haha. I would say maybe try not to hang out with your friends who do them a lot even though it sucks cause obviously there your friends and you can't just get up and walk away especially when you're in college and they live like all over your hall haha