Mac编辑文件保存遇到E45: 'readonly

2018-12-05  本文已影响182人  ShineYangGod

这总是发生在我身上。我作为普通用户登录,并开始使用VIM编辑文件。编辑完成后,当我试图保存文件时,我没有足够的权限保存文件。我必须关闭文件,登录为root并重新开始编辑。下面是VIM中的给定错误:

E45: 'readonly' option is set (add ! to override)

解决的办法:
:w !sudo tee %

:w – write

!sudo – call shell sudo command

tee – the output of write (:w) command is redirected using tee

% – current file name

上一篇 下一篇

猜你喜欢

热点阅读