Trying to rewrite a file with vim as a user without write permission.
Can't open file for writing
Press ENTER or type command to continue
Get angry.
You can switch to the root user and edit again. At that time.
:w !sudo tee %
: w! (Save content) sudo tee (write the resulting output to a file as root user) % (Path to the currently loaded buffer file)