Vim无法保存文件(E212) [英] Vim Can't Save File (E212)

查看:155
本文介绍了Vim无法保存文件(E212)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,当我使用vim some/path/newfile创建文件时,vim允许我对其进行编辑,仅在尝试保存更改时抱怨.

Sometimes when I create a file using vim some/path/newfile, vim lets me edit it, only to complain when I attempt to save my changes.

E212 Can't open file for writing.

这似乎仅在新文件位于系统目录中时发生.

This appears to happen only when the new file is located in a system directory.

:w!不会覆盖此错误.

如何编写当前缓冲区,而不必将其保存到临时位置,退出,然后使用sudo重命名?

How can I write the current buffer, without having to save it to a temporary location, exit, then rename it using sudo?

推荐答案

这将要求您提供root密码,然后根据需要保存您的更改:

This will ask you for the root password, then save your changes as you requested:

:w !sudo tee %

然后在提示符下键入(L)oad,以在文件保存后重新加载.

Then type (L)oad at the prompt, to re-load the file after it is saved.

这篇关于Vim无法保存文件(E212)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆