Sorry about that. I reccomend you to get some help. Either in a rehab center or a doctor. If you feel umconfortable talk about it with people you trust. It can be a family member or perhaps a friend.
I once read a book called the power of habit. It explains how habits are created and tricks to change them.
Habits work this way: cues-action-result.
you have to identify your cues. When do you get the urge to smoke marijuana?. For example, some do it on stressing times or when they feel lonely. (there can be other situations that trigger you).
The trick is to change the action for another one that can satisfy the urge.
Personally, when my then gf broke up with me i drowned my sorrows in the gym. I knew i had to move my mind to something else, so i tried to look for a healthy alternative that fulfill the purpose of distracting me from the sorrow.
Maybe a hobby, a sporty activity or something like that can help you.
And about the break up: Society conditioned us to see rejection as a negative thing, but it helps to avoid continuing on relationships that will not work out, either by incompatibility, lack of attraction or because it is harmful for at least one of the parts.
there are 7.53 thousand millions of person in the earth, so there is at least one guy that will love you and that you will love a lot.
Take care and wish you the best!