II Samuel22:1

וַיְדַבֵּר דָּוִד לַיהוָה אֶת־דִּבְרֵי הַשִּׁירָה הַזֹּאת בְּיוֹם הִצִּיל יְהוָה אֹתוֹ מִכַּף כָּל־אֹיְבָיו וּמִכַּף שָׁאוּל׃

And David spoke to the Eternal the words of this song on the day the Eternal rescued him from the hand of all his enemies and from the hand of Shaul (Saul).

II Samuel 22:1

וַיְדַבֵּר דָּוִד לַיהוָה

Shmuel II / II Samuel 22:1 · Remez

II Samuel 22:1

וַיְדַבֵּר דָּוִד לַיהוָה אֶת־דִּבְרֵי הַשִּׁירָה הַזֹּאת בְּיוֹם הִצִּיל יְהוָה אֹתוֹ מִכַּף כָּל־אֹיְבָיו וּמִכַּף שָׁאוּל׃

And David spoke to the Eternal the words of this song on the day the Eternal rescued him from the hand of all his enemies and from the hand of Shaul (Saul).

Remez רֶמֶז

Two versions of one song

When an author rewrites a text for another book, the changes tell a lot about who it is written for. This song appears both in the Book of Samuel and in Psalms, with differences.

Minchat Shai: here it says "from the hand (מִכַּף) of Shaul (Saul)", and in Psalms "from the hand (מִיַּד) of Shaul". Malbim explains why the song is written twice: David composed it in his youth as a general song for all rescues and sang it each time, and in old age, gathering the Psalms as a prayer book for every person, he changed its words so it would fit anyone surrounded by troubles.

How Minchat Shai and Malbim explain it

Minchat Shai And from the hand (וּמִכַּף) of Shaul

In the Book of Psalms: "and from the hand (וּמִיַּד) of Shaul".

Malbim And David spoke

This whole psalm the sweet singer of Israel placed in his Book of Psalms (Tehillim / Psalms 18), and in our commentary on his Psalms we explained his words, by the good hand of the Eternal upon us. But why is it brought here too, and why are there many changes and substitutions in words and letters here? We must listen to the words of Don Yitzchak Abarbanel (מהרי״א): David composed this song in his youth, while in the midst of his troubles, and made it general for all troubles, so that every time the Eternal saved him from trouble he would sing this song. And this is what is written: "on the day the Eternal rescued him from the hand of all his enemies and from the hand of Shaul": every time he was saved, he sang these words to the Eternal. And in this book none of David's other songs and praises were written, only this song, because it is general and he sang it always.

And King David, peace be upon him, in his old age gathered all his praises into a separate book for one who prays in solitude, so that he could pour out his speech before the Almighty about all the particulars each person needs in his life, and find a psalm or prayer to pray. And it has wondrous properties, for it was composed in the holy spirit, as written in the book Shimush Tehillim. And this psalm he wrote there a second time, so that a person surrounded by many troubles who was saved from them, like David, would pray with it. But since [the book] was made for the needs of the one who prays in solitude, "a prayer of the afflicted when he faints", he changed many things so they would fit the needs of an individual. And so this prince, [Abarbanel], found sound reasons for all the differences between here and the Book of Psalms. Look in his words, for there is nothing to add to them. And the commentary on this precious psalm is written by me in the Book of Psalms, for that is its place, and I will not repeat it here needlessly. "To His dwelling you shall seek, and come there", if the Almighty will be with me.

Takeaway

"The sweet singer of Israel" is what David is called in his last words (Shmuel II / II Samuel 23:1).
"The prince" (השר) is what Malbim calls Don Yitzchak Abarbanel, the Bible commentator. He calls him so also in his commentary on Shemot (Exodus) 23:20.
Shimush Tehillim is a book on which psalm to read in which trouble.
"A prayer of the afflicted when he faints" opens Tehillim / Psalms 102 (Tehillim / Psalms 102:1). "To His dwelling you shall seek, and come there" (Devarim / Deuteronomy 12:5): Malbim playfully sends the reader to his commentary on Psalms.