I've had this in my vimrc for years:
" Let :w!! gain sudo privileges without closing and reopening vim
cmap w!! w !sudo tee % >/dev/null " Let :w!! gain sudo privileges without closing and reopening vim
cmap w!! w !sudo tee % >/dev/nullNo comments yet.