Write Changes with SUDO Permission in Vim

Have you ever made this mistake…

You open a config file with READ permissions, but needed to WRITE changes elevated (with “root” permissions)?

Here’s the perfect solution:

:write !sudo tee %

And here’s my full break down of the command:

Leave a comment