Ubuntu – Gedit as the default editor in crontab

command linecrondefault-programseditorgedit

How do I make gedit the default editor for crontab?

So far I've tried:

sudo update-alternatives --install /usr/bin/gnome-text-editor gnome-text-editor /usr/bin/gedit 100

and

sudo update-alternatives --install /usr/bin/editor editor /usr/bin/gedit 100

No luck so far. (maybe I just need to reboot?)

Best Answer

Open .profile file using your desired editor:

gedit ~/.profile

Add this line to the file and save it:

export EDITOR=gedit

Logout and re-login. Now when you use crontab -e it would open gedit.

Remember that it's going to set gedit as default editors for other commands too, if you want it to only affect crontab, then you can create an alias:

alias crontab='EDITOR=gedit crontab'