Since I use Digital Ocean and Linode cloud VPS, I need to use VIM a lot when I need to update configuration files on server. And this happens to me a lot. Trying to save a read-only file after modifying lots of lines. It is a frustrating situation. Then I found this blog post http://www.geekyboy.com/archives/629. You can actually save a read-only file in VIM!
This is the command
:w !sudo tee %
You may read detail explanation on how the command works here. http://stackoverflow.com/questions/2600783/how-does-the-vim-write-with-sudo-trick-work/7078429#7078429