Last Updated: February 25, 2016
·
563
· zhangchiqing

Save Readonly file in Vim

You finish editing a file in Vim and are about to save it, but realize it's a readonly file which does not allow writing without sudo. So how to save it without quitting Vim? Try the following command

:w ! sudo tee % > /dev/null