是否可以更改 Vim 命名其交换/备份/撤消文件的方式?
为了避免困惑,我在 ~/.vimrc
中设置了选项,将这些文件转储到 ~/.vim/tmp/{swap,backup,undo}
>;然而,当我经常编辑不同目录中具有相同名称的文件时,我经常会得到许多无法区分的文件,并且 Vim 有时难以恢复。
理想情况下,我想对所有这些辅助文件使用持久撤消的命名方案 (%path%to%file.undo
);没有明显的方法来设置它,但是可以使用 Buf{Read,Write}
宏来完成吗?
最佳答案
我的 .vimrc
中有这个,它用完整路径名和百分号命名交换文件,正如您所描述的那样:
" Store swap files in fixed location, not current directory.
set dir=~/.vimswap//,/var/tmp//,/tmp//,.
关键是目录末尾的//
。请参阅 :help dir
中的注释:
- 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 - 更改 Vim 交换/备份/撤消文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4331776/