"How precious and weighty also are Your thoughts to me, O God! How vast is the sum of them! If I could count them, they would be more in number than the sand. When I awoke, [could I count to the end] I would still be with You." Psalm 139:17-18.
In Psalm 139, David worships God as one who, though supreme, yet is loving and conscious of man. God how wonderful you are. Let's have a quick run through the chapter:
1You have searched me, Lord, and you know me.
2You know when I sit and when I rise; you perceive my thoughts from afar.
3You discern my going out and my lying down; you are familiar with all my ways.
4Before a word is on my tongue you, Lord, know it completely.
5You hem me in behind and before, and you lay your hand upon me.
6Such knowledge is too wonderful for me, too lofty for me to attain.
2You know when I sit and when I rise; you perceive my thoughts from afar.
3You discern my going out and my lying down; you are familiar with all my ways.
4Before a word is on my tongue you, Lord, know it completely.
5You hem me in behind and before, and you lay your hand upon me.
6Such knowledge is too wonderful for me, too lofty for me to attain.
David knew that God is all-knowing (omniscient), but what amazes him is that God knows his thoughts, so God understands him.
We often have a particular friend(s) who gets us more than others. For David, it was God (more than that, it was only God at that time - having lost his closest friend Jonathan, 1 Samuel 18:1). You can imagine the feeling of; wow, God gets me, he actually gets me well (verse 3 and 6). Isn't it wonderful to know that, no matter what, God gets you? Matthew 6:8,32. God understands you.
7Where can I go from your Spirit? Where can I flee from your presence?
8If I go up to the heavens, you are there; if I make my bed in the depths, you are there.
9If I rise on the wings of the dawn, if I settle on the far side of the sea,
10even there your hand will guide me, your right hand will hold me fast.
11If I say, “Surely the darkness will hide me and the light become night around me,”
12even the darkness will not be dark to you; the night will shine like the day, for darkness is as light to you.
8If I go up to the heavens, you are there; if I make my bed in the depths, you are there.
9If I rise on the wings of the dawn, if I settle on the far side of the sea,
10even there your hand will guide me, your right hand will hold me fast.
11If I say, “Surely the darkness will hide me and the light become night around me,”
12even the darkness will not be dark to you; the night will shine like the day, for darkness is as light to you.
If I described a friend of mine with verse 7 to 12, your response would probably be 'Sam, your friend stalks a lot', but the good thing is, this is not stalking :)
David here describes the intimacy of Presence. Not just that God is somewhere watching over you, but he is also as close as 'inside of you' to order your steps. Isn't it good to know that the Supreme Creator (omnipotent, omniscient, omnipresent) lives inside of you? And that, with you, he goes through everything you go through? Hebrews 13:5. God never leaves you.
13For you created my inmost being; you knit me together in my mother’s womb.
14I praise you because I am fearfully and wonderfully made; your works are wonderful, I know that full well.
15My frame was not hidden from you when I was made in the secret place, when I was woven together in the depths of the earth.
16Your eyes saw my unformed body; all the days ordained for me were written in your book before one of them came to be.
17How precious to me are your thoughts, God! How vast is the sum of them!
18Were I to count them, they would outnumber the grains of sand—when I awake, I am still with you.
14I praise you because I am fearfully and wonderfully made; your works are wonderful, I know that full well.
15My frame was not hidden from you when I was made in the secret place, when I was woven together in the depths of the earth.
16Your eyes saw my unformed body; all the days ordained for me were written in your book before one of them came to be.
17How precious to me are your thoughts, God! How vast is the sum of them!
18Were I to count them, they would outnumber the grains of sand—when I awake, I am still with you.
To really, fully understand the heart of verse 13 to 18, we need 1 Samuel 16:1-13 - which puts it all in context. Verse 15 - my frame was not hidden from you...verse 16 - all the days ordained for me were written in your book... I Samuel 16:1-13 is a passage where Samuel was sent by God to anoint David as king of Israel, but at the initial instance, his brothers were preferred over him, in his absence. But God's purpose still stood. Now David writes, my frame was not hidden from you. God never forgets us, even when we 'miss and mix-up' things - when we are absent from the place of blessing, He always calls us back to purpose. O, thank You LORD for Your INFINITE MERCY and GRACE. Hebrews 13:5. God never forsakes you.
Wow, I'm already blown up here (like David). Just pause a minute, and thank God for mercy, thank Him for grace.
19If only you, God, would slay the wicked! Away from me, you who are bloodthirsty!
20They speak of you with evil intent; your adversaries misuse your name.
21Do I not hate those who hate you, Lord, and abhor those who are in rebellion against you?
22I have nothing but hatred for them; I count them my enemies.
23Search me, God, and know my heart; test me and know my anxious thoughts.
24See if there is any offensive way in me, and lead me in the way everlasting.
20They speak of you with evil intent; your adversaries misuse your name.
21Do I not hate those who hate you, Lord, and abhor those who are in rebellion against you?
22I have nothing but hatred for them; I count them my enemies.
23Search me, God, and know my heart; test me and know my anxious thoughts.
24See if there is any offensive way in me, and lead me in the way everlasting.
If you are following the flow of the passage with us, you will see there seem to be a sudden shift in flow from verses 19 to 24 (especially 19 to 22). Actually, it's still in context, these verses are more of response (for us, response to grace). Remember, the passage began with a man who is in awe of God's love, and amazed to have finally found someone (God) who gets him. At this point, he does not want to hurt that relationship - not by ungodly relationships (verses 19-22), not even by ungodly selfish desires (verses 23-24). So, he ends with these words (which we now often sing), and we can all make it our prayer:
Search me, God, and know my heart; test me and know my anxious thoughts. See if there is any offensive way in me, and lead me in the way everlasting.
God bless you.