Trick answer: Replace it. Quit it, yes but of course easier said than done. Replace it....
Bad habits come from stress, boredom, emotional crisis, life trauma but with all of these, there is always something you can do to alleviate pain, boredom or stress. A habit that causes happiness, progress or a step in a more positive direction.
Think of your habit, it usually makes you feel good, or some type of high or just literally relieves that nervous itch. Biting nails, playing with your hair's dead ends, smoking, drinking, over eating, binge eating...etc
Figure out when or why you're doing it. Now, you can recognize the feeling and be more conscious of the reason why you do it, allowing for more self awareness to avoid self destruction.
Find a replacement
If you spend too much time on social media, try spending half of it on a new podcast, audio book, regular book, or work...or like the good old days, go outside and appreciate real life off the gram.
Eliminate the enabling factors
So if you drink, try to cut out a few days at the bar
If you smoke, try not to take a smoke break or make sure you don't have a pack in the car.
If you eat cookies, don't keep them in the house.
Surround yourself with influences of inspiration
Hang with people and crowds that will uplift you, support you and those who inspire you. Stop being around toxic energies.