Vim: Can't open file for writing
1 min read

Vim: Can't open file for writing

If you forget to edit a file as a superuser like sudo vim file and you don’t want to leave your existing vim session, you can use the following snippet.

:w !sudo tee % > /dev/null