How does the vim “write with sudo” trick work?
In :w !sudo tee %… % means “the current file” As eugene y pointed out, % does indeed mean “the current file name”, which is passed to tee so that it knows which file to overwrite. (In substitution commands, it’s slightly different; as :help :% shows, it’s equal to 1,$ (the entire file) (thanks to … Read more