Search code examples
vimswapfile

Special path of vim swap files for files in certain location


Due to my configuration, vim stores swap files in the same directory as the edited file. In general, that is ok, but not in the folder ~/ftp_mount (and all directories below). In this directory I mount an ftp server.

With

:set dir=/some/path

one can change the location in which vim stores the swap files (vim documentation). Is it possible to restrict this configuration to ~/ftp_mount and all directories below?


Solution

  • How about using an autocmd on the directory you want to apply this setting to (~/ftp_mount)

    autocmd BufNewFile,BufRead ~/ftp_mount/* set dir=/some/path