Vim: Can’t open file for writing

January 2, 2014 — Leave a comment

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

Mike

Posts Twitter Facebook

My name is Michael Le, and I am a web developer.

No Comments

Be the first to start the conversation.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.