如何在Vim中更改SWP文件的文件夹路径 [英] How to change the folder path for swp files in Vim

查看:529
本文介绍了如何在Vim中更改SWP文件的文件夹路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在远程服务器上的一个项目中工作.我不想在服务器上安装交换文件.我希望将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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆