Sometimes when I edit a file which require root permission (e.g. files under /etc), but I forget run vim as sudo.
After edit finished, and type :wq to save
:wq
To force a save use the following command
:w !sudo tee %
It will prompt you for your password.
The mentioned trick with tee is nice; if you need this often I'd recommend the SudoEdit plugin, which offers a :SudoWrite command (and even a sudo: protocol handler).
tee
:SudoWrite
sudo: