Last Updated: September 09, 2019
·
238
· blazarecki

Vim: save a readonly file

Sometime you want to edit a file but you forgot to use sudo.

Here the solution :

Place this into your .vimrc

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

Then when you want to save a readonly file just use

:w!!

Vim will ask your password and it's done !

Picture

Hope it's helpful