zoukankan      html  css  js  c++  java
  • vim出现“E212: Can't open file for writing”的处理办法

    在使用vim 对文件或配置进行编辑的时候,在保存时发现当前用户没有写权限。又不想放弃当前编辑的内容,怎么办呢?

    来自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总是这么可爱大笑

  • 相关阅读:
    Fiddler抓包整理
    redis集群
    php性能加速:Opcache
    细说一下position(定位),以及其他的小知识
    css的小知识3
    css小知识 2
    网页背景的属性及使用
    css小知识
    属性的特征和一些选择器的使用
    浏览器介绍和一些简单的代码
  • 原文地址:https://www.cnblogs.com/zhangeamon/p/6552483.html
Copyright © 2011-2022 走看看