E212: Can't open file for writingIf you use vim, you have probably come across this error before.
Press ENTER or type command to continue
It normally happens when you don't have permission to write to your chosen destination.
The temporary solution has traditionally been to save your changes to somewhere where you do have permissions (such as /tmp or ~), then use sudo to cp it across, or re-open the file in vim with sudo.
A collegue at work showed me a great trick to get around this when it happens (Thanks Rich). All you have to do is add this to your .vimrc file:
Then when you come across this error again, instead of of using :w you can use :W and it will prompt you for your sudo password before saving.command! W w !sudo tee % > /dev/null
Works brilliantly!
0 comments:
Post a Comment