There is an old question here about best practices to store swap files, and there is an answer by flemingfleming (who haven't visited the site since 2018) where he suggested the following:
set directory^=$HOME/.vim/swap//
For what reason is the ^ character is used there?
Yes, I know I can open :h set, but I simply don't understand.
:se[t] {option}^={value} *:set^=* Multiply the {value} to a number option, or prepend the {value} to a string option. When the option is a comma-separated list, a comma is added, unless the value was empty. Also see |:set-args| above.
'directory'is a comma-separated list. – D. Ben Knoble Sep 01 '22 at 23:56