Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot create backup file(add ! to overwrite)

Tags:

linux

bash

vi

Need help. I have been editing a text file in vi , and i was able to save the changes before but now i am getting the above error whenever i am typing command to save the file. Please help .

like image 657
Aditya Avatar asked Dec 08 '11 08:12

Aditya


4 Answers

You can, as vi (or, more likely, vim) is saying force a write by doing:

:w!

Alternatively, write the file to an alternative location:

:w! /path/to/other/location

To check where your backup files are being written (normally):

:se backup? backupdir? backupext? 

Try to touch a file in that directory and see if your Operating System gives you an error to enlighten you as to why your editor cannot write there.

like image 140
Johnsyweb Avatar answered Oct 19 '22 18:10

Johnsyweb


Had the same problem. Tried all options as above but it did not work. Then when I checked my disk space, it was full. Once I cleared some space then I was able to write back to file again.
P.S: This was in linux.

like image 28
naamadheya Avatar answered Oct 19 '22 19:10

naamadheya


Had the same problem. It was because I installed vimconf as root. You need to change rights of files in ~/.vim directory and change owner to your user.

sudo chmod 0750 ~/.vim
sudo chown user ~/.vim
like image 8
Piotr Pęczek Avatar answered Oct 19 '22 17:10

Piotr Pęczek


I had this same problem. Turns out it was due to running out of disk space. try creating a file using Ex) touch test.txt. If you get a message saying touch: cannot touch test.txt: No space left on device you will need to clear up space on your disk

like image 4
Aaron Oommen Avatar answered Oct 19 '22 18:10

Aaron Oommen