This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed last year.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(14)
您可以按照
vi
(或更可能是vim
)所说的方式强制写入:或者,将文件写入另一个位置:
要检查备份的位置正在写入文件(正常情况下):
尝试
触摸
该目录中的文件,看看您的操作系统是否给出错误,以提示您为什么编辑器无法在那里写入。You can, as
vi
(or, more likely,vim
) is saying force a write by doing:Alternatively, write the file to an alternative location:
To check where your backup files are being written (normally):
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.有同样的问题。尝试了上述所有选项,但没有成功。然后当我检查我的磁盘空间时,它已满。一旦我清除了一些空间,我就可以再次写回文件。
PS:这是在linux下。
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.
有同样的问题。这是因为我以root身份安装了vimconf。您需要更改 ~/.vim 目录中文件的权限并将所有者更改为您的用户。
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.
我也有同样的问题。事实证明这是由于磁盘空间不足造成的。尝试使用 Ex)
touch test.txt
创建一个文件。如果您收到一条消息:touch:无法触摸test.txt:No space left on device
,您将需要清理磁盘上的空间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 sayingtouch: cannot touch test.txt: No space left on device
you will need to clear up space on your disk我不知道原因是什么,但我在 .vimrc 中通过
backupdir
从.
移动到~/.vim/backups
,它为我解决了这个问题:我想象某种工具正在使用我正在编辑的文件的文件夹(在我的例子中是 Visual Studio 2013),但我不确定。
I don't know what the cause was, but I moved by
backupdir
from.
to~/.vim/backups
in my .vimrc and it solved it for me:I'd imagine some sort of tool was using the folder the file I was editing it in (Visual Studio 2013, in my case), but I'm not sure.
我已经解决了这个问题:
其中“{user}”字段是您的用户名。
I've fixed this with:
where the "{user}" field is your user-name.
备份位置可以在
.vimrc
中给出,例如:您可能需要自己创建这个目录。
Backup location can be given in
.vimrc
, e.g.:You may need to create this directory yourself.
在 vi 中,尝试:
:help w!
给出以下信息:from within vi, try:
:help w!
gives the following information:以下是一些命令来验证这一点并查找磁盘空间被占用的位置。就我而言,它是超过 20GB 的 PHP 日志。
Here are some commands to verify this and find where the disk space is being taken. In my case it was the PHP log at over 20GB.
另一种可能性是您将备份放在一个集中位置(例如 /tmp),并以 root 身份编辑特定文件。然后,备份文件将归 root 所有,并且以后您作为凡人将无法写入。
在这种情况下,上面触摸 /tmp/atestfile 的建议不会显示问题!你将拥有写入权限,没问题,但没有 vim 尝试写入的特定备份文件的权限。
以 root 身份删除该文件 (sudo rm)。
注意原因w!有效是因为 vim 写入文件而不写入备份文件(尽管出现错误,您仍然坚持写入)。
Another possibility is that you put your backups in a centralized location (e.g. /tmp) and you edited a particular file as root. Then, the backup file will be owned by root and un-writeable by you as a mere mortal later.
In this case, the suggestion above to touch /tmp/atestfile won't show the problem! You'll have write permissions, no problem, but not to the particular backup file vim is trying to write.
Remove the file as root (sudo rm).
Note that the reason w! works is because vim writes the file without writing a backup file (you're insisting that it write despite the error).
我刚刚开始使用 nvim,我发现我的问题是我借来的预制 vimrc 文件中有一个预设源。
和这里的其他人一样,创建该备份目录清除了我的错误消息(~/.backup/)
I just started using nvim and I found my issue was that my borrowed premade vimrc file had a preset source in it.
Like others here, creating that backup directory cleared my error message (~/.backup/)
我认为还值得一提的是,问题可能不是您在备份目录中拥有的权限。对我来说,我正在编写的文件位于根拥有的目录中,尽管该文件是用户拥有的。
I think it's also worth mentioning that the problem might not be the permissions you have in the backup directory. For me the file I was writing was in a root owned directory, although the file was user owned.
如果您正在编辑不属于您的文件,即您正在编辑 root 拥有的目录中的文件,则可能会出现此消息。
你可以在目录中使用这个命令来查看哪些内容是你所拥有的,哪些内容是root所拥有的。
在这种情况下,hello 文件归用户所有,但目录
.
归 root 所有。如果您尝试使用 vim 或 neovim 编辑文件并保存,则会显示错误无法写入备份文件(添加!以覆盖)
。因此,要解决这个问题,您可以
并且它应该按预期工作。
This massage might appear if you are editing a file that is not owned by you, i.e. you are editing a file in a directory owned by root.
you can use this command in the directory to see what is owned by you and what is owned by root.
in this case hello file is owned by user but the directory
.
is owned by root. if you tried to edit the file and save with vim or neovim, it will display errorCan't write to backup file (add ! to override)
.so to solve this you can
and it should work as expected.
简单,首先释放一些空间,然后重试..如果仍然存在相同的问题,则尝试使用 :w 保存!
Simple first free some space and try again..if still same issue then try to save with :w!