When I'm editing a system file with Neovim, I try to save it as root using
:w !sudo tee %
However, instead of being asked for password, I get
:w !sudo tee %
sudo: no tty present and no askpass program specified
shell returned 1
How can I solve this?
I see suggestion here How to fix 'sudo: no tty present and no askpass program specified' error? to tell sudo not to ask for password. I'd rather not do that (or somehow do it safely without letting nvim just modify all system files).