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 <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.
% is vim shorthand for the file open in this buffer.
Btw: sudo -e some_file. Try it.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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 <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.%
is vim shorthand for the file open in this buffer.Btw:
sudo -e some_file
. Try it.