Change default Linux / UNIX text editor from VI to Pico

Posted on in Categories , , , , , , , , , last updated August 30, 2007

Q. I find vi hard to use. How do I change my default text editor from vim / vi to Pico under Debian Linux?

A. To use and change an editor to edit your text message, set the variable EDITOR to the pathname of the vi / vim binary file. You need to use export or set command for the same purpose.

Many Linux / UNIX command read shell EDITOR environment variable to determine which editor to use for editing a text file.

Set default text editor to pico

Type the command as follows:
$ which pico
Output:

/usr/bin/pico

Now setup a new text editor:
export EDITOR=/usr/bin/pico
OR
export EDITOR=pico

Add above line to ~/.bashrc file:
$ vi ~/.bashrc
Append text as follows:
export EDITOR=pico
Close and save the file. There is no no need to reboot system.

Also you can add alias if you want:
alias vi=/usr/bin/pico

16 comment

  1. just a small suggestion:
    alias pico=’nano -w’

    thats because not every distro has pico symlinked to nano (nano is the open source pico) and because nano by default wraps long lines (-w).

    also someone might be interested in seting TERM to linux
    export TERM=linux
    so he can use home/end/delete and numpad correctly in nano and also in shell

    hope im not too much offtopic (a)

  2. export EDITOR=$(which nano)
    in /home/$USER/.profile
    .profile is the last of the shell initialisation files to be loaded. The $(which nano) – or whatever editor of your taste- is a bash trick. everything in $(…) will be evaluated, so `which nano` will be evaluated to /usr/bin/nano or herever it’s located.

  3. Need to change the default editor (that opens files) from EMACS to VIM.

    The $EDITOR env variable doesn’t help (this is already vi). If anyone knows, can they help?

    Thanks.

  4. Need to change the default editor (that opens files) from EMACS to VIM.

    The $EDITOR env variable doesn’t help (this is already vi). If anyone knows, can they help?

    Thanks.

    Update: Solved. No need for follow-up

  5. for Ubuntu user:
    sudo update-alternatives –config editor
    # Type the number which corresponds to Vim here (after installing it) then press Enter.

Leave a Comment