If you forget to open a file in vim a sudo/root, you can simply do in vim (sudo needs to be installed):

```bash
:w !sudo tee % 
```