Psalm 119:11—“Your word I have hidden in my heart, That I might not sin against You.”
If you want to avoid sin, that verse pretty well says it all. The idea of “hidden in my heart” means it is deeply embedded there, so deeply that it strongly influences the way we live. David isn’t talking about hiding it so nobody else can find it. He is talking about God’s Word being so entrenched in his heart and life that it will help him, first, to recognize sin when he sees it, and secondly, to help prevent him from committing sin. Anyone who loves God enough to “hide” His word in their heart will certainly be strongly motivated to reject what God rejects, i.e., sin.
David, of course, isn’t talking about sinless perfection here. No human ever attains that, and even David was guilty of heinous sins on occasion—including adultery and even murder. The flesh of every human has its moments of temptation and weakness. But, if we truly want to live a godly life, it is imperative that we “hide the word of God” in our hearts, bury it deeply there, make it our constant meditation, and practice it constantly.
Sin can become a habit. But then, so can righteousness. It simply depends on which one we do the most.