How to change default editor for crontab

In this article, we will see how to change default editor for crontab. The crontab -e command will check the environment variables $EDITOR and $VISUAL for an override of the default text editor.

Now we are going to change the default editor for crontab to vi or vim.


We are going to change temporary and permanent.

1. Change default editor for crontab to vi Temporarily:
2. Change default editor for crontab to vi Permanently:

First time if you run crontab -e, it asks us to select editor of any of the following choices. Then, we have to provide numbers. That option is permanent for the user.

no crontab for david - using an empty one Select an editor. To change later, run 'select-editor'. 1. /bin/nano <---- easiest 2. /usr/bin/vim.tiny 3. /bin/ed Choose 1-3 [1]:1

In my environment default text editor for crontab is selected as nano editor. Now, I am going to change it to vi or vim.

crontab -e

How to change default editor for crontab

1. Change default editor for crontab to vi Temporarily:
Following method is for current session. If we disconnect the session and reconnect them default editor for crontab will be same as original.

export EDITOR=vi

if you want to give vim, then just replace vi with vim.

Now, run crontab -e. Then, it will open with vi editor.

2. Change default editor for crontab to vi Permanently:
Following method is permanent
Open profile.

vi ~/.profile

Then add $EDITOR=vi
Then save and quit.

Now, run crontab -e. Then, it will open vi as text editor for crontab.