A Few tips to stay away from sins
Since Satan is our avowed enemy, and he is always bent on leading us astray, we cannot guard ourselves against him, unless we are extremely vigilant. It is not different from walking in a jungle full of prickly thorns, hard rocks, and dangerous pits: we cannot escape unscathed without extreme caution. Here are a few tips to follow, which should--insha Allah--help us in our efforts to save ourselves from sins:
1) You need to motivate yourself by visualizing clearly the pain and dire consequences of sins you wish to shun. Do this by listing the consequences of sins, including the eternal torments in hell-fire. List the dire consequences and fix them in your mind so vividly so that you are forced to change your association of sins with pleasure; hence no sooner you think of a sin, all you imagine is pure pain and suffering;
2) Once you have successfully linked sins with pain and suffering, you are better prepared to motivate yourself to do the opposite: good deeds. Now list all the benefits of doing them, and visualize the pleasure that they entail. The Prophet said, virtue leads to jannah. Jannah is the eternal bliss about which the Prophet said, '(the bliss of paradise is) such the like of which no eyes have seen, no ears have heard about, and no mind has ever conceived'.
3) If you wish to shun a bad habit, you need to acquire the opposite virtue. So no sooner you are prompted to do a sin, hasten to do that which is good instead;
4) Make yourself busy with good deeds. As Imam Shafi'i said, if a person is not occupied with what is good, Satan will surely find ways of making him occupied with his works. So, decide how would you like to spend your time each day? Remember the time is all that we have to buy our place in jannah. So killing time is not an option for a person who believes in heaven and hell.
5) Keep company with the righteous people who would inspire you to be good--those who are conscious of Allah and are motivated to learn and practice Islam.
6) Establish Prayer and do so consciously, while meditating, and feeling reverence for Allah;
7) Make your tongue supple with dhikr Allah (remembrance of Allah): We can fight Satan only with the weapon of dhikr. The Prophet said, 'Satan runs through the blood veins of the children of Adam; but when he makes dhikr, Satan retreats'. So through dhikr and seeking refuge in Allah, and imploring Allah's help, we can surely guard against sins.