Set your default editor for things like crontab, visudo, etc...

Discussion in 'Command Line' started by Rob, Nov 14, 2011.

  1. Rob

    Rob Administrator Staff Member

    Messages:
    565
    Likes Received:
    171
    Trophy Points:
    43
    One thing I hate is going in to edit a crontab or run visudo and being forced to use pico instead of my text editor of choice (vim). Here's how to change the default editor for your system..


    Open up /etc/bashrc in your favorite editor and look for the lines:
    Code:
    export EDITOR="pico"
    export VISUAL="pico"
    
    Now, change it to the one you'd like to use for tools like crontab or visudo:
    Code:
    export EDITOR="vim"
    export VISUAL="vim"
    
    You'll have to log out then back in, but now the default editor on your system is of your choosing.
  2. carbon333

    carbon333 New Member

    Messages:
    87
    Likes Received:
    4
    Trophy Points:
    0
    It would be better to modify users ~/.bashrc instead of changing system-wide configuration (and it also would work on a system which you don't have root access to).
  3. Nick Hood

    Nick Hood New Member

    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    I'm running a Centos machine and made the suggested change by creating a new file custom.sh in /etc/profile.d containing the two lines:

    Code:
    export EDITOR="nano"
    export VISUAL="nano"
    (I can't stand vim).

Share This Page