I made lengthy changes to a configuration file on a Ubuntu Linux computer with the vi editor. Unfortunately, I forgot to sudo first, so now I'm in the editor, but can't save my changes because of missing rights. Can I retroactively sudo the user on that terminal, or what would be the best course of action to take?
:w !sudo tee %
I actually find myself using this way to do it more frequently now:
:%!sudo tee %
I think it's a little more intuitive, as I know what
:%! does, whereas I don't have a visceral understanding of
:w !. Also, it's easy to miss the very important space between the
w and the