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

  • 相关阅读:
    [spring] SpEL
    [spring学习2] 装配
    [spring] proxyMode
    [spring] @PropertySource
    [一些问题] 在vscode中添加jar库
    [spring] ApplicationContext相关问题
    gradle 打包
    [spring学习1] IoC容器
    spring快速开始
    准备要写的笔记备忘录
  • 原文地址:https://www.cnblogs.com/zhangeamon/p/6552483.html
Copyright © 2020-2023  润新知