Previous Section  < Day Day Up >  Next Section

Recipe 6.15. Setting Your Default Editor

6.15.1 Problem

By now, you're totally sold on Vim and JOE. But some programs, such as crontab and quota, require use of the default editor, and the editor you get by default is some creaky old monster. How do you set the default editor to something you like?

6.15.2 Solution

Edit your environment variables, in ~/.bashrc or ~/.bash_profile. ~/.bashrc is preferable, because it applies to all shells opened during a session. ~/.bash_profile is read only at login.

Add these lines to ~/.bashrc, or modify any existing entry:

EDITOR=vim

VISUAL=$EDITOR

export EDITOR VISUAL

Obviously, you'll enter the editor of your choice. Usually it is better to use a console text editor like JOE, Pico, Vim, or Emacs. You may select an X editor like Kwrite or GEdit, but keep in mind there may be times when X is not available, so these won't always work. It is important to use both the VISUAL and EDITOR variables. VISUAL is an older term, leftover from ancient times, but some programes still look for it.

Make sure your ~/.bash_profile calls ~/.bashrc:

# include .bashrc if it exists

if [ -f ~/.bashrc ]; then

         source ~/.bashrc

fi

6.15.3 See Also

  • bash(1)

  • Chapter 17 of LPI Linux Certification in a Nutshell

    Previous Section  < Day Day Up >  Next Section