Vim: forgot sudo?

Has it ever happened to you that you were modifying file that you had no permission to write in VIm? Most of us quit the editor, sometimes save the file to a temp location, then edit it again as root. The thing is - you don't really have to!

Once you open your file, you can save it as an input to external command. To do that, simply call:

:w !<command>

in this particular case, it's:

:w !sudo tee %

good luck!

No comments:

Post a Comment