Skip to main content

Command Palette

Search for a command to run...

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

Published
1 min read
How to Load Neovim init.lua or init.vim in Sudo Mode Linux
J

I'm a self-taught web developer who likes sharing my knowledge, helping people.

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

More from this blog

Code with Luis. Tutorials Laravel, Vuejs, and More.

27 posts