When you realized you forgot sudo

https://lemmy.world/post/13497675

When you realized you forgot sudo - Lemmy.World

Is there an editor that can request root privileges without restarting it? That would be quite useful.
Save write-protected files with sudo automatically

(n)vim + suda.vim.
GitHub - lambdalisue/suda.vim: 🥪 An alternative sudo.vim for Vim and Neovim, limited support sudo in Windows

🥪 An alternative sudo.vim for Vim and Neovim, limited support sudo in Windows - lambdalisue/suda.vim

GitHub
In vim, in normal mode you can do: :w !sudo tee %

Apparently that doesn’t work in NeoVim, so recently I installed the suda plugin.

Personally, I just doas nvim and then the file name that needs root access, but it’s a handy plugin in case I forget.

GitHub - lambdalisue/suda.vim: 🥪 An alternative sudo.vim for Vim and Neovim, limited support sudo in Windows

🥪 An alternative sudo.vim for Vim and Neovim, limited support sudo in Windows - lambdalisue/suda.vim

GitHub

??? I used this in neovim twice today

:w !sudo tee % then reload when it asks.

It’s a simple trick in Vim:

stackoverflow.com/a/7078429

For the lazy: :w !sudo tee > /dev/null %

How does the vim "write with sudo" trick work?

Many of you have probably seen the command that allows you to write on a file that needs root permission, even when you forgot to open vim with sudo: :w !sudo tee % The thing is that I don't get ...

Stack Overflow
kate does this in KDE, but it’s not cli.
micro ftw, no need to even memorize a command, it’ll just ask if you want to use sudo
Yeah, in emacs you use tramp to open the file with /sudo: