Unable to change the default editor in terminal


My default editor is pico at my server. I use Bash and Linux.

I tried to change Vim to be my default editor unsuccessfully by

echo vim > $EDITOR

How can I change Vim my default editor?


The following code does not work in .bashrc

export EDITOR='vim'
7/28/2012 7:09:43 PM

Accepted Answer


export EDITOR=vim

to your .bashrc should really do the trick. (There a no quotes necessary and, depending on what quotes you used, they may be the cause for your problem.)

You must open a new shell (or enter source ~/.bashrc at the prompt) after modifying .bashrc for the modification to take effect.

What is the program from which you want vim to be started?

EDIT: I haven't used git, but the documentation (http://www.kernel.org/pub/software/scm/git/docs/git-commit.html) reads ``The editor used to edit the commit log message will be chosen from the GIT_EDITOR environment variable, the core.editor configuration variable, the VISUAL environment variable, or the EDITOR environment variable (in that order).''

So check whether one of these variables is set:

git config --get-all core.editor

For me,

export VISUAL=vim

solved the problem.

6/25/2013 4:12:42 AM

You can use the git config option core.editor to set the editor of your liking, eg nano

$ git config [--global] core.editor "nano"

You can also change this by editing the .gitconfig file in your home directory (global) or git repo (create it if it doesn't exist) if you don't have shell access:

  name = Your Name
  email = your@email.address
  editor = nano

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow