Stupid vim tricks

Quick hit today. Ever open a file in vim, only to realize that you need sudo to write to it? Usually, you have to exit out of vim, open vi as sudo, and make your changes again. No more!

:w !sudo tee %

This command is writing the file (:w) to the pipe (!) that executes sudo and then copies the pipe contents (tee) to a file (%, which is a placeholder for the current file in vim).



I'm currently working at NerdWallet, a startup in San Francisco trying to bring clarity to all of life's financial decisions. We're hiring like crazy. Hit me up on Twitter, I would love to talk.

Follow @chase_seibert on Twitter