It is very annoying to see message “E212: Can’t open file for writing” when trying to save file.

Hopefully there is a simple solution (a bit longer but without “W12 Warning“):

:execute ':w !sudo tee % > /dev/null' | :edit!

Look at commandlinefu.com for more solutions like :W command below:

:command W :execute ':silent w !sudo tee % > /dev/null' | :edit!