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.
  • 1
    The end of the first sentence and middle sentence: 'directory' is a comma-separated list.
    – D. Ben Knoble
    Sep 1, 2022 at 23:56
  • @D.BenKnoble I still don't understand how is it related here.
    – john c. j.
    Sep 2, 2022 at 0:45
  • “prepend” means add to/before the start.
    – Rich
    Sep 2, 2022 at 7:10

1 Answer 1


As help states:

or prepend the {value} to a string option.

Option directory is a string, so if you have set directory=path1,path2 and then do set directory^=path0, result directory would be path0,path1,path2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.