简体   繁体   中英

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. I'm using 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?

Thank you.

Adding the following line to my ~/.vimrc puts .swp files for currently open buffers under /tmp

set directory=/tmp

If you've tried this without issues are you able to verify that vim is reading your vimrc at all?

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:

set backupdir=~/tmp//

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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