A Commentary, Critical, Practical, and Explanatory on the Old and New Testaments, by Robert Jamieson, A.R. Fausset and David Brown  at sacred-texts.com
psa 31:1The prayer of a believer in time of deep distress. In the first part, cries for help are mingled with expressions of confidence. Then the detail of griefs engrosses his attention, till, in the assurance of strong but submissive faith, he rises to the language of unmingled joyful trust and exhorts others to like love and confidence towards God. (Psa. 31:1-24)
Expresses the general tone of feeling of the Psalm.
psa 31:2He seeks help in God's righteous government (Psa 5:8), and begs for an attentive hearing, and speedy and effectual aid. With no other help and no claim of merit, he relies solely on God's regard to His own perfections for a safe guidance and release from the snares of his enemies. On the terms "rock," &c., (compare Psa 17:2; Psa 18:2, Psa 18:50; Psa 20:6; Psa 23:3; Psa 25:21).
psa 31:5commit my spirit--my life, or myself. Our Saviour used the words on the Cross [Luk 23:46], not as prophetical, but, as many pious men have done, as expressive of His unshaken confidence in God. The Psalmist rests on God's faithfulness to His promises to His people, and hence avows himself one of them, detesting all who revere objects of idolatry (compare Deu 32:21; Co1 8:4).
psa 31:7hast known my soul, &c.--had regard to me in trouble.
psa 31:8shut me up . . . enemy--abandon to (Sa1 23:11).
large room--place of safety (compare Psa 18:19).
psa 31:9mine eye, &c.--denotes extreme weakness (compare Psa 6:7).
grief--mingled sorrow and indignation (Psa 6:7).
soul and . . . belly--the whole person.
psa 31:10Though the effects ascribed to grief are not mere figures of speech--
spent . . . consumed--must be taken in the modified sense of wasted and decayed.
iniquity--or, suffering by it (see on Psa 40:12).
psa 31:11among--or, literally, "from," or, "by" my enemies. The latter clauses describe the progress of his disgrace to the lowest degree, till,
psa 31:12he is forgotten as one dead, and contemned as a useless broken vessel.
psa 31:13For--introduces further reasons for his prayer, the unjust, deliberate, and murderous purposes of his foes.
psa 31:14In his profession of trust he includes the terms of the prayer expressing it.
psa 31:15times--course of life.
deliver . . . hand--opposed to "shut me up," &c., of Psa 31:8.
psa 31:16Make . . . shine--(Compare Num 6:25; Psa 4:6). Deprecating from himself, he imprecates on the wicked God's displeasure, and prays that their virulent persecution of him may be stopped.
psa 31:19God displays openly His purposed goodness to His people.
psa 31:20the secret of thy presence--or, covering of Thy countenance; the protection He thus affords; compare Psa 27:5 for a similar figure; "dwelling" used there for "presence" here. The idea of security further presented by the figure of a tent and a fortified city [Psa 31:21].
psa 31:22For I said--literally, "And I said," in an adversative sense. I, thus favored, was despondent.
in my haste--in my terror.
cut off . . . eyes--from all the protection of Thy presence.
psa 31:23the Lord . . . proud doer--literally, "the Lord is keeping faith," that is, with His people, and is repaying, &c. Then let none despair, but take courage; their hopes shall not be in vain.