Vi打开某个文件,保存时提示只读时的简单做法

Vi打开某个文件,保存时提示只读时的简单做法

命令行模式下:
输入
<pre>
:w !sudo tee %
</pre>
再输入
<pre>
:q!
</pre>
现在已经保存并退出了。


用法:
<pre>
:w !sudo tee %
</pre>


:w = Write a file.<br >
!sudo = Call shell sudo command.<br >
tee = The output of the vi/vim write command is redirected using tee.<br >
% = Triggers the use of the current filename.<br >
Simply put, the ‘tee’ command is run as sudo and follows the vi/vim command on the current filename given.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容