I often type 'vim /path/to/file' without thinking if I need sudo or not. But you can add sudo powar afterwards with:
:w !sudo tee %
You'll have to enter your password of course and then press enter a couple of times to confirm the process. That will write your changes to the file with sudo. If you try to quit out vim will warn you don't have permissions. You can just ignore that with :q!
Remember, with great power comes great responsibility :)