//View Tip #630
Similar Tips
» Quickly empty a file in vi
» Making vim oneliners
» Making shell scripts executable via editor hooks


Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
I often open a file and start editing only to realize later that I don't have write permissions when I get the old "E212: Can't open file for writing" error.

The vim command below can be user to save the file without the need to save it to a temp file and then copy it back again.

:w !sudo tee %

View Comments »


Add your comment

Comments are currently disabled
No Comments

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit