The Holy Spirit doesn't leave when you mess up or feel distant. Jesus promised a helper who stays, and Paul wrote that believers are united with the Lord as one spirit. Trust the Spirit's presence by faith, not by how you feel.
Chapters
This is where many believers make their mistake in their thinking about the Holy Spirit. They think that the Holy Spirit is someone whose presence they have to earn, that his presence depends upon their performance, that his nearness, that his faithfulness depends upon their faithfulness. Listen, if his nearness, if his presence in our lives depended upon our faithfulness, all of us would lose the Holy Spirit every single day. The Holy Spirit will not abandon you. He abides as a faithful friend. Even when you make a mistake, even when you feel like he's at a distance, we don't go by feelings. We go by faith. We can know, we can trust that the Holy Spirit abides. He does not come and go. Jesus said, I'll send another. He will never leave you. Paul the Apostle writes in 1 Corinthians 6:17, he that is joined to the Lord is one spirit with him. The Holy Spirit, who is God, the Holy Spirit who dwells in you, the Holy Spirit who is that personal faithful friend, doesn't just dwell with you. He dwells within you. You are already one with the Holy Spirit.