How to edit Readonly File inside VIM

After making some changes at a file, then I discover it is a read only file. You can try :w! but it is not always working. Here another command that would help you out.

:w !sudo tee %

After that choose Load File instead of OK then you have your new file.