nvim’s bang executes the command directly, then pipes the output to nvim
As a result, sudo (without args) can’t work in nvim as it doesn’t have a tty to prompt the user for passwords. Nvim also used to do what vim did, but they found out spawning the tty was causing other issues (still present in vim) so they changed it.
:w !sudo tee %
Warning: does not work for neovim
Neovim, the one true vim, why hast thou forsaken me.
Iirc the specific reason behind this is
As a result, sudo (without args) can’t work in nvim as it doesn’t have a tty to prompt the user for passwords. Nvim also used to do what vim did, but they found out spawning the tty was causing other issues (still present in vim) so they changed it.
There must be more to this. I just launched a terminal and created a file to test with nvim on arch and it works perfectly fine.
Take a file, sudo chown root:root filename, sudo chmod 700 filename, edit with nvim and save with :w !sudo tee % then reload. Works fine.
I’m on arch with suckless st.
Edit:
Made a demo vid - https://youtu.be/YKZuAvoSW5g
sure it works in neovim
I didn’t do any editing since it’s just to prove a point, but I think it does fine.
Removed by mod