This is very common problem that every software engineer has may suffered since from student level.
In vi/vim editor,Suppose you have created a file and saved it using root user.
And now there is a situation that you have opened this file using without root user and you are trying to write in file and save it.
Then we get an error like file is readonly or you can not save it.
what normal people do –
Normally people quit the file without saving(as they not able to save the file).
(:q!) and they change the user to root user / change the permission of file,open the file and write in it and save it.
But as we are software engineer, we have habit to forgot, and in a scenario mentioned in above problem statement we dont want to do the stuff as normal people does or want to save the time and efforts (haha).
What this blog reader do in the above senario(solution)-
(:w !sudo tee %)
esacpe : !sudo tee % and enter ….by doing this you will able to save the changes in the file. And you have to do :q! to exit from the files