简体   繁体   English

添加到 vimrc 以在 Ubuntu 上的 /tmp 中存储 .swp 文件的行是什么

[英]What is the line to add to vimrc for storing .swp files in /tmp on Ubuntu

I feel like I've literally tried everything, but no matter what I add to vimrc, I can't get it to store its annoying .swp files in /tmp.我觉得我真的什么都试过了,但是无论我向 vimrc 添加什么,我都无法将其烦人的 .swp 文件存储在 /tmp 中。 I'm using Ubuntu 16.04.我正在使用 Ubuntu 16.04。 I've obviously looked up this issue extensively, but again, no command I enter seems to work.我显然已经广泛地查找了这个问题,但同样,我输入的命令似乎都不起作用。 I always end up with:我总是以:

E510: Can't make backup file
(add ! to override)

Things I've tried:我尝试过的事情:

set backupdir=$~/tmp//
set directory=$~/tmp//
set backupdir=~/tmp//
set backupdir=$HOME~/tmp//
set backupdir=/tmp//

I mean you name it, I've tried it.我的意思是你的名字,我已经试过了。 So, explicitly, what is the exact code I need to type in vimrc to make it so vim saves it's .swp files in my temporary folder, instead of cluttering my workspace?所以,明确地说,我需要在 vimrc 中输入的确切代码是什么,以便 vim 将它的 .swp 文件保存在我的临时文件夹中,而不是弄乱我的工作区?

Thank you.谢谢你。

Adding the following line to my ~/.vimrc puts .swp files for currently open buffers under /tmp将以下行添加到我的 ~/.vimrc 将当前打开的缓冲区的 .swp 文件放在 /tmp 下

set directory=/tmp

If you've tried this without issues are you able to verify that vim is reading your vimrc at all?如果您尝试过没有问题,您是否能够验证 vim 是否正在读取您的 vimrc?

It appears the issue was I didn't really understand what ~ means.看来问题是我真的不明白 ~ 是什么意思。 I created a folder called 'tmp' in my home directory, and from there used:我在我的主目录中创建了一个名为“tmp”的文件夹,并从那里使用:

set backupdir=~/tmp//

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM