בשלום - בלא פחד. In peace (בְּשָׁלוֹם - be-shalom) - without fear.
וטעם יחדו – הרבים והוא עמהם. And the meaning of together (yachdav) – [refers to] the many [his followers], and he [David] with them.
ומלת בדד – בלמ"ד, או בחסרונה שוה. And the word alone (badad) – [whether] with a Lamed [prefix] (le-vadad, as in the verse), or in its absence [badad], it is equivalent [in meaning].
וככה מלת לבטח – ויש בטח והנה ה' בדד ינחנו. ונכון הוא שהשם לבדו וככה זה או טעמו, או היו יחדו עמי, או הייתי לבדד והטעם לבדי תושיבני. And similarly the word in safety (la-vetach) – and [the form] betach also exists [with the same essential meaning]. And behold [in contrast, (Deuteronomy 32:12) says]: "Ad-nai alone (badad) did lead him." And it is correct [that badad in Deuteronomy 32:12 refers to] HaShem alone. And so perhaps here [the meaning is 'You alone' make me dwell]. Or, [going back to the verse's structure:] '[My followers were] together (yachdav) with me.' Or [perhaps taking yachdav and levadad together or focusing on the latter part:] 'I was alone (levadad).' And the meaning [of the end] is: You make me alone (levadi) dwell [in safety].