How To Save A File In Vim / Vi With sudo

To save a file, simply type the following command:
:w !sudo tee %

:w – Write a file (actually buffer).
!sudo – Call shell with sudo command.
tee – The output of write (vim :w) command redirected using tee.
% – The % is current file name. 

Comments

Popular posts from this blog

Check MySQL query history from command line

Installing chocolatey on Windows