You’re in vim, you forgot to sudo, the file is read only and you have loads of changed you don’t feel like saving off to /tmp and playing the copy file shell game.
[esc]:w !sudo tee %
it shoves the current buffer through tee (termina adapter) with sudo privs
vim will warn you that the file changed, just [esc]:q! and don’t let it save, you already saved it.
You’re in vim, you forgot to sudo, the file is read only and you have loads of changed you don’t feel like saving off to /tmp and playing the copy file shell game.
[esc]:w !sudo tee %
it shoves the current buffer through tee (termina adapter) with sudo privs vim will warn you that the file changed, just [esc]:q! and don’t let it save, you already saved it.
I don’t see how this is relevant but thanks for the tip.
I offered one for !ssh, then noticed people were giving other obscure tips so i offered this one.