I just use :w !sudo tee % when that happens. I don't come across that situation enough to justify a mapping, and the command is easy to reinvent when needed.
:w !sudo tee %
w <file> writes to a file, and can be redirected to an external program's stdin if file is !<command>
sudo tee <file> takes its input and writes it to both stdout and file.
sudo tee <file>
% is vim shorthand for the file open in this buffer.
Btw: sudo -e some_file. Try it.
sudo -e some_file
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.