Ellicott's Commentary On The Whole Bible
2 Samuel 22 - Introduction
XXII.
This chapter, with numerous slight variations, constitutes Psalms 18, the first verse here serving as the title there, with only such differences as the nature of the Book of Psalms required. With this title may be compared the inscriptions of other historical psalms, as Exodus 15:1; Deuteronomy 31:30.
No more definite time can be assigned for the composition of this hymn than that already given in its title. 2 Samuel 22:51 shows that it must have been after the visit of Nathan promising the perpetuity of David’s kingdom.
As comment upon this psalm will naturally be expected in connection with the Book of Psalms, only the differences between these two copies will here be spoken of. On the whole, the form given in the Psalms seems to be the later, and to have been in some points intentionally altered — probably by David himself — to adapt it to the exigencies of liturgical worship; but it must also be remembered that minor differences inevitably grow up in the copying of manuscripts age after age, and that much of the lesser variation is undoubtedly due to this cause.