Writing files as root in vim

Posted on Wed 10 August 2011 in misc

I do this at least once a day; open a file in vim, make changes, then get reminded that I didn't do it using sudo.

simple one-liner fixes this.

:w !sudo tee %

Thanks to http://www.cyberciti.biz/faq/vim-vi-text-editor-save-file-without-root-permission/ for that one.

vim