[debu@DebaTestBox ~]$ sudo !!
Forgot 'sudo' before editing a file:
Believe me this is the most frustrating one, and it happens to me a lot to me. You edited quite a few in the file and when try to save&xit( :wq!) you see an error as below
E212: Can't open file for writing
Press ENTER or type command to continue
Well, the below is a savior un this kind of scenario
:w !sudo tee %
this will ask your password the there in, and you are done. All your edits are now recorded by Vim editor.
Hope it helps!