Ir para conteúdo principal

Getting root permission to change a file without leaving Vim

Lucas Caton

Lucas Caton

@lucascaton
You know when you open a file on Vim and after making changes and trying to save the file, Vim tells you that you need root permission to do so?
This is what most people do to solve it:
  • Copy the content of the file to my clipboard
  • Close Vim
  • Re-open it with sudo
  • Paste it and try to save it again
Well, turns out there's an easier way to achieve the same thing:
vim
:w !sudo tee %
Thanks to my friend Diogo Lisboa for teaching me this!

Post atualizado em 01/06/2022 10:00:00