Hacker News new | ask | show | jobs
by overgun77 4908 days ago
Not really a unix command, but a vi command that has been really useful, specially if you do lots of editing protected files and want to keep your custom vim configuration:

!sudo tee %

2 comments

Need to send the contents of the file to that command. Otherwise it effectively empties the file. (typo?)

:%!sudo tee %

What vi mode is that entered in?
Normal mode (:help :! for more information on this command).
What benefit does

    :!sudo tee %
have over doing it at the command line other than filling in the current filename for you? I suspect the original poster meant something like "gg!Gsudo tee %".
:w !sudo tee %