首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Vi取消用户权限

Vi取消用户权限
EN

Stack Overflow用户
提问于 2013-02-09 04:04:09
回答 1查看 179关注 0票数 1

如果你在vi或vim中打开一个文件,但没有写的权限,有没有一种方法可以在不放弃所有更改并重新打开的情况下使用sudo su

目前,我必须放弃所有更改,关闭vi,然后关闭su vi

EN

回答 1

Stack Overflow用户

发布于 2013-02-09 04:10:12

如果你安装了the Sudo Edit plugin,你会得到命令:SudoWrite,它会要求你输入根密码。然后它将以root用户身份写入文件,这非常方便。我经常使用它来编辑/etc/中的内容。

从文档中:

代码语言:javascript
复制
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.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14780457

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档