[4.13.12-1-ARCH with gnome3 and gdm on Xorg]
I already have set my VISUAL and EDITOR env-vars to vim
. Similarly I did try SYSTEMD_EDITOR="vim"; export SYSTEMD_EDITOR
in my ~/.bashrc, to no avail.
When modifying unit files in Arch (systemd) via
$ sudo systemctl edit _unit_
I find myself staring at nano
. Life is too short and I want vim
by all means. How do I do this ?
Best Answer
First method, you can add this line to
~/.bashrc
:And then
sudo visudo
and add this line:Start new bash session to take effect, then run
sudo systemctl edit <foo>
as usual.Second method is use
update-alternatives
:Install your desired
editor
, e.g.vim.gtk3
:Then choose your desired
editor
:Third method is direct set the
EDITOR
on runtime:The precedence are first method > third method > second method.
Don't try to set "GUI" editor such as
gedit
because Why don't gksu/gksudo or launching a graphical application with sudo work with Wayland? and Gedit uses 100% of the CPU while editing files