2. Know why you want to do it.
3. Replace negative information with positive information
4. Plan for the formation of good habits (for example, specify the frequency and gradually reduce it).
In view of the two bad habits you mentioned, it is actually very easy to do. Divert your attention and concentrate on your work and study. The most terrible thing about people is to be idle and do nothing. If you don't enrich yourself with other things, you will definitely have these bad habits.
Like these:
Bad habits are formed unconsciously. -Roman poet Ovid
Bad habits are like cakes. It is better to break them than to keep them. Liddell, an English poet, famously said about bad habits.
If not controlled, bad habits will soon become a necessity in your life. -Augustine, an ancient Roman thinker
It is much easier to change good habits than bad ones, which is one of the great sorrows of life. -Mao Mu, English novelist, playwright and essayist.
Our worst virtue begins with our bad habits when we were young. Our main education is in the hands of wet nurses. -Goethe, German playwright, poet and thinker
If good habits are a kind of moral capital, then, to the same extent, bad habits are moral debts that cannot be paid off. -ushinski,19th century Russian educator.