user privilege within vi?

Possible Duplicate:
How does the vim “write with sudo” trick work?

This situation always happen: I try to vi a configuration file but I forget to add sudo before it, and when I try to save it, vi prompt me that this file is read only.

How can I change to super-user privilege without get out of vi and re-edit that file?


这适用于vi和vim中的我:

:w !sudo tee %

cmap w!! %!sudo tee > /dev/null %

Add the line in ~ /. Vimrc and do: w!! to keep with sudo


通常我将它保存在temp :w /tmp/foo.txt然后sudo cp。

链接地址: http://www.djcxy.com/p/49572.html

上一篇: /etc/apt/sources.list“E212:无法打开文件进行写入

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