only when saving
Submitted by Benjamin Melançon on December 22, 2007 - 4:40pm
in
Searched words:
vi how to save read only file
vim vi saving a read-only file
If you've used Debian or any other type of Linux or Unix-like for editing
files on your server, at some point you will have done a whole bunch of editing
without seeing the "READ ONLY" warning, and then... you try to save.
Sometimes, throwing an exclamation point on your w is enough:
:w!
http://uw714doc.sco.com/en/FD_create/Stopping_vi.html
having to search for something as simple as this is what I get for using the
ZZ shortcut all the time.
Does not always work.
That is, you should sudo vi document.txt up front when
needed.
But if you've done all this editing you don't want to lose, all is not lost!
Save it to your user directory:
:w! ~/tempfile.txt
And then just copy over that mean readonly file, using sudo this time:
sudo mv ~/tempfile.txt
meanreadonly.txt