vim出現“E212: Can't open file for writing”的處理辦法

來自stackoverflow
For some reason the file you are writing to cannot be created or overwritten.
The reason could be that you do not have permission to write in the directory
or the file name is not valid.

Vim has a builtin help system, I just quoted what it says to :h E212. You might want to edit the file as a superuser like sudo vim FILE. Or if you don't want to leave your existing vim session (and know have proper sudo rights), you can issue:

:w !sudo tee % > /dev/null

Which will save the file. ”

這樣文件的所有者是root,依然沒有寫的權限。只需更改文件的所有者和組:

[sany@sanshui code]$  sudo chown 用戶名:組名  文件名

當你用上述方法強制寫的時候,會提示如下:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

【linux總是這麼可愛大笑

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章