Passage
With the merciful thou wilt shew thyself merciful; with an upright man thou wilt shew thyself upright;
With the merciful thou wilt shew thyself merciful; with an upright man thou wilt shew thyself upright;
Psalms 18:23 I was also upright before him, and I kept myself from mine iniquity.
Psalms 18:24 Therefore hath the LORD recompensed me according to my righteousness, according to the cleanness of my hands in his eyesight.
Psalms 18:25 With the merciful thou wilt shew thyself merciful; with an upright man thou wilt shew thyself upright;
Psalms 18:26 With the pure thou wilt shew thyself pure; and with the froward thou wilt shew thyself froward.
Psalms 18:27 For thou wilt save the afflicted people; but wilt bring down high looks.
The verse centers on "merciful", "thou", "wilt", "shew", "thyself", and "upright". It is saying that the verse draws attention to "merciful" and "thou", so its meaning should be read from those terms before moving to application.
The nearby context moves from verse 24's "Therefore hath the LORD recompensed me according..." into verse 26's "With the pure thou wilt shew thyself...", so "merciful" and "thou" belong inside that flow. In Psalms context, the local focus is worship, trust, the LORD's kingship, and covenant mercy.
A plain takeaway is to answer the verse's own emphasis on "merciful" and "thou" with trust shaped by these words, not by a vague optimism outside the passage.