How to Load Neovim init.lua or init.vim in Sudo Mode Linux

How to Load Neovim init.lua or init.vim in Sudo Mode Linux

One of the biggest problems that I found when I was starting with Neovim was how to execute it in Sudo mode because my config file was always lost and did not work as I expected, here is the solution

We need to make an alias:

export SUDO_EDITOR="nvim"
alias "sudoedit"='function _sudoedit(){sudo -e "$1";};_sudoedit'

Now, we need to add these lines in the correct profile file: ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc and make a source for example: source ~/.zshrc

If everything goes well we can use Neovim in sudo mode!!!!!.

not_bad_meme.jpeg