Vi escelate user permission

This question already has an answer here:

  • Can I gain root permission without leaving vim? 2 answers
  • How does the vim “write with sudo” trick work? 7 answers

  • If you install the Sudo Edit plugin you get the command :SudoWrite which will ask you for your root password. It will then write the file as root, it's very convenient. I use it frequently for editing things in /etc/.

    From the documentation:

    2.2 SudoWrite                            *SudoWrite*
    
    :[range]SudoWrite[!] [file]
    
    SudoWrite will write the given file using any of the configured methods for
    superuser authtication. It basically does something like this: >
    
         :w !sudo tee >/dev/null file
    
    If no filename is given, SudoWrite will try to write the current file name.
    If the current buffer does not contain any file, it will abort.
    
    You can specify a range to write just like |:w|. If no range is given, it will
    write the whole file. If the bang argument is not given, the buffer will only
    be written, if it was modified.
    
    Again, you can use the protocol handler sudo: for writing.
    
    链接地址: http://www.djcxy.com/p/49570.html

    上一篇: vi中的用户权限?

    下一篇: Vi escelate用户权限