*Minor differences ignored. Grouped by changes, with first version listed as example.
And he said, The LORD [is] my (b) rock, and my fortress, and my deliverer;
(b) By the diversity of these comfortable means, he shows how his faith was strengthened in all temptations.
And he said, The Lord is my rock, and my fortress, and my deliverer. See Gill on Psalm 18:2.
2-Samuel 22:2-4 form the introduction.
2 Jehovah is my rock, my castle, and my deliverer to me;
3 My Rock-God, in whom I trust:
My shield and horn of my salvation, my fortress and my refuge,
My Saviour; from violence Thou redeemest me.
4 I call upon the praised one, Jehovah,
And I am saved from my enemies.
This introduction contains the sum and substance of the whole psalm, inasmuch as David groups the many experiences of divine deliverance in his agitated life into a long series of predicates, in all of which he extols God as his defence, refuge, and deliverer. The heaping up of these predicates is an expression both of liveliest gratitude, and also of hope for the future. The different predicates, however, are not to be taken as in apposition to Jehovah, or as vocatives, but are declarations concerning God, how He had proved himself faithful to the Psalmist in all the calamities of his life, and would assuredly do so still. David calls God וּמצרתי סלעי (my rock, and my castle) in Psalm 31:4 as well (cf. Psalm 71:4). The two epithets are borrowed from the natural character of Palestine, where steep and almost inaccessible rocks afford protection to the fugitive, as David had often found at the time when Saul was pursuing him (vid., 1-Samuel 24:22; 1-Samuel 22:5). But whilst David took refuge in rocks, he placed his hopes of safety not in their inaccessible character, but in God the Lord, the eternal spiritual rock, whom he could see in the earthly rock, so that he called Him his true castle. לי מפלטי (my deliverer to me) gives the real explanation of the foregoing figures. The לי (to me) is omitted in Psalm 18:2, and only serves to strengthen the suffix, "my, yea my deliverer.' "My Rock-God," equivalent to, God who is my Rock: this is formed after Deuteronomy 32:4, where Moses calls the Lord the Rock of Israel, because of His unchangeable faithfulness; for zur, a rock, is a figure used to represent immoveable firmness. In Psalm 18:3 we find צוּרי אלי, "my God" (strong one), "my rock," two synonyms which are joined together in our text, so as to form one single predicate of God, which is repeated in 2-Samuel 22:47. The predicates which follow, "my horn and my salvation-shield," describe God as the mighty protector and defender of the righteous. A shield covers against hostile attacks. In this respect God was Abraham's shield (Genesis 15:1), and the helping shield of Israel (Deuteronomy 33:29; cf. Psalm 3:4; Psalm 59:12). He is the "horn of salvation," according to Luther, because He overcomes enemies, and rescues from foes, and gives salvation. The figure is borrowed from animals, which have their strength and defensive weapons in their horns (see at 1-Samuel 2:1). "My fortress:" misgab is a high place, where a person is secure against hostile attacks (see at Psalm 9:10). The predicates which follow, viz., my refuge, etc., are not given in Psalm 18:3, and are probably only added as a rhythmical completion to the strophe, which was shortened by the omission of the introductory lines, "I love thee heartily, Jehovah" (Psalm 18:1). The last clause, "My Saviour, who redeemest me from violence," corresponds to אחסה־בּו in the first hemistich. In Psalm 18:4, David sums up the contents of his psalm of thanksgiving in a general sentence of experience, which may be called the theme of the psalm, for it embraces "the result of the long life which lay behind him, so full of dangers and deliverances." מהלּל, "the praised one," an epithet applied to God, which occurs several times in the Psalm (Psalm 48:2; Psalm 96:4; Psalm 113:3; Psalm 145:3). It is in apposition to Jehovah, and is placed first for the sake of emphasis: "I invoke Jehovah as the praised one." The imperfects אקרא and אוּשׁע are used to denote what continually happens. In 2-Samuel 22:5 we have the commencement of the account of the deliverances out of great tribulations, which David had experienced at the hand of God.
*More commentary available at chapter level.