Possible Duplicate:
vim re-edit as root
I could have sworn I saw this question asked. But after looking though every search result for "vi" I'm stumped/lazy.
I've opened a file, made an edit and now I realize it's read only and I've opened it as non-root me.
I think you want something like this:
I first saw it on commandlinefu. The quotes are only necessary if the file path contains spaces.
i do this occasionally, and if the changes i've made are trivial, i just exit and edit it again as root.
otherwise i save the file to /tmp, and mv/cp it as root to where it really belongs later. and use chown/chgrp/chmod to fix the ownership/perms.
consider adding this line to your vimrc:
Try this http://blog.sriunplugged.com/2009/12/how-to-save-file-in-vi-not-opened-with-sudo/ . This is what you want i guess