He vowed to give charity every time he committed a sin, then he committed sin but did not give charity
Question

                I had a problem with a sin, and one day after doing it I regretted it deeply and began to curse myself. Then I raised my finger and said, literally, “I vow that if I do this habit again, I will give five hundred riyals in charity, and if I do it another time I will give this amount in charity again,” i.e., each time I did it I would give five hundred riyals in charity. But I did it again, many times.

 My question is: What should I do in this case, knowing that I have not even given a single riyal in charity yet, and I do not know how many times I did it, but it has been a long time? Please advise me, may Allaah reward you with good..
Praise be to Allah.
    Firstly: 

    Making vows so that one will not commit sin is something that 
    was done by some of the salaf, in order to punish themselves and train 
    themselves not to commit sin, but that was with regard to things that thy 
    were able to do. 

    Harmalah said: I heard Abu Wahb say: I vowed that every time 
    I backbit about a person I would fast for a day and that wore me out, 
    because I used to backbite and fast. So I intended that every time I backbit 
    about a person I would give a dirham in charity instead, and because of my 
    love of money I gave up backbiting. 

    Al-Dhahabi said: This, by Allaah, is how the scholars were. 
    This is one of the fruits of beneficial knowledge. 

    Siyar A’laam al-Nubala’, 9/228 

    It is better for a Muslim to refrain from committing sin 
    without making vows or oaths, so that he will not expose himself to breaking 
    that oath or not fulfilling that vow. 

    Secondly: 

    If the one who makes a vow intends to prevent himself from 
    doing a particular deed, then either he will break that vow or he will not. 
    If he does not break it then he does not have to do anything. If he does 
    break it then he is given the choice of two things: either to fulfil the vow 
    or to offer kafaarat yameen (expiation for breaking a vow).   

    Ibn Qudaamah said in al-Mughni (13/461): 

    If he makes a vow to prevent himself or someone else from 
    doing something, or to encourage him to do something, such as saying, ‘If I 
    speak to Zayd, then I am bound to perform Hajj, or give my wealth in 
    charity, or fast for a year,” this is a vow and the ruling is that he has 
    the choice between fulfilling what he swore to do, in which case he does not 
    have to do anything else, or breaking his vow. So he has the choice between 
    doing what he vowed to do or offering kafaarat yameen. This is called a vow 
    of desperation and anger, and he does not have to fulfil it. This is the 
    view of ‘Umar, Ibn ‘Abbaas, Ibn ‘Umar, ‘Aa’ishah, Hafsah and Zaynab bint Abi 
    Salamah. It is also the view of al-Shaafa’i. 

    Shaykh Ibn ‘Uthaymeen was asked: 

    I am a young man who was negligent then Allaah guided me, but 
    I still commit some sins. I have tried to repent from them many times but I 
    could not. I said to myself that I should vow that if I repeated this sin, I 
    would fast for two consecutive months. But the Shaytaan tempted me and I 
    said that the vow in this case is like a yameen (oath) for which kafaarah 
    (expiation) may be offered. Then I committed that sin again. What should I 
    do, may Allaah reward you with good? Is it permissible for me to feed sixty 
    poor persons, because that is easier for me than fasting? Please note that 
    Allaah has blessed me by helping me to repent from this sin now. 

    He replied: 

    Firstly: A Muslim should be determined, resolved and strong 
    in resisting haraam things without swearing oaths or making vows, and he 
    should do what he is obliged to do without swearing oaths or making vows. 
    Allaah says (interpretation of the meaning): 
“They swear by Allaah 
    their strongest oaths, that if only you would order them, they would leave 
    (their homes for fighting in Allaah’s Cause). Say: Swear you not; (this) 
    obedience (of yours) is known (to be false). Verily, Allaah knows well what 
    you do”

    [al-Noor 24:53]

    But some people may be incapable of controlling themselves so 
    they resort to vows and oaths to make themselves do what they are obliged 
    to, or to refrain from doing haram things. The scholars (may Allaah have 
    mercy on them) mentioned that the vow which is intended to help one to 
    refrain from something haraam or do something obligatory comes under the 
    ruling of a yameen (oath). Hence the brother who asked this question has to 
    offer kafaarat yameen as an expiation for this oath, by feeding ten poor 
    persons, giving each one of them a mudd (or two handfuls) of rice or wheat, 
    or clothing ten poor persons, or freeing a slave. He has the choice of doing 
    one of these three things. If he cannot do any of them, then he has to fast 
    for three consecutive days, because Allaah says in Soorat al-Maa'idah 
    (interpretation of the meaning): 
“Allaah will not punish 
    you for what is unintentional in your oaths, but He will punish you for your 
    deliberate oaths; for its expiation (a deliberate oath) feed ten Masaakeen 
    (poor persons), on a scale of the average of that with which you feed your 
    own families, or clothe them or manumit a slave. But whosoever cannot afford 
    (that), then he should fast for three days”

    [al-Maa’idah 5:89]

    With regard to feeding the poor, it is permissible to make 
    food, lunch or dinner, and invite ten poor people to come and eat. 

    Fataawa Islamiyyah, 3/501.