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

2015-04-02  本文已影响976人  ForUs

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.

上一篇 下一篇

猜你喜欢

热点阅读