Recipe 6.15. Setting Your Default Editor

 < Day Day Up > 

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

     < Day Day Up > 


    Linux Cookbook
    Linux Cookbook
    ISBN: 0596006403
    EAN: 2147483647
    Year: 2004
    Pages: 434

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net