Vim Can't Save File (E212)

This will ask you for the root password, then save your changes as you requested:

:w !sudo tee %

Then type (L)oad at the prompt, to re-load the file after it is saved.


Add this line to your .vimrc:

cmap w!! %!sudo tee > /dev/null

and then you can do

:w!!

when you get into this position, and it will write the file using sudo. Very handy.


You can mkdir first, then save it.