如何在 Vim 中更改 swp 文件的文件夹路径 [英] How to change the folder path for swp files in Vim
问题描述
我正在远程服务器上的一个项目中工作.我不想在服务器上有交换文件.我希望 Vim(当然还有 gVim)的所有交换文件都保存在指定目录中.我怎么能那样做?
I'm working at a project on a remote server. I don't want to have the swap files on the server. I would like all swap files for Vim (and, of course, gVim) to be saved on the specified directory. How could I do that?
推荐答案
您可以将 directory
选项设置为您希望 vim 存储其交换文件的位置,例如:
You can set the directory
option to the location that you want vim to store its swap files, e.g.:
mkdir -p $HOME/.vim/swapfiles # this dir must exist vi does not create it
" $HOME/.vimrc
:set directory=$HOME/.vim/swapfiles//
我使用尾随双路径分隔符,因为,来自帮助文档:
I use trailing double path separators because, from the help docs:
对于 Unix 和 Win32,如果目录以两个路径分隔符//"或\"结尾,交换文件名将从文件的完整路径构建,所有路径分隔符都替换为百分比%"迹象.这将确保保留目录中文件名的唯一性.
For Unix and Win32, if a directory ends in two path separators "//" or "\", the swap file name will be built from the complete path to the file with all path separators substituted to percent '%' signs. This will ensure file name uniqueness in the preserve directory.
这篇关于如何在 Vim 中更改 swp 文件的文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!