tags:

views:

1600

answers:

4

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?

[edit]

The following code does not work in .bashrc

export EDITOR='vim'
+1  A: 

export EDITOR vim

should do the job

Your command does not work. I tried it also with $EDITOR unsuccessfully.
Masi
It has to be:EDITOR=vimexport EDITORor if you use bash justexport EDITOR=vim
njsf
+1  A: 

I don't have an EDITOR environmental variable. Perhaps you could specify your distribution? My bashrc does define this:

alias vi='vim'

and supposedly if vim can't find a file called .vimrc in your home directory it runs in "compatibility mode" and you only get vi features until you say type :nocp

If it is based on your EDITOR environmental variable you would set it like this in BASH:

export EDITOR='vim'
Philluminati
+6  A: 

Adding

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:

echo $GIT_EDITOR $VISUAL $EDITOR
git config --get-all core.editor

For me,

export VISUAL=vim

solved the problem.

Jochen Walter
@Jochen: The above command does not work. The program is Git from which I want vim to be started.
Masi
Just out of curiosity: Did using the VISUAL environment variable solve your problem?
Jochen Walter
echo $GIT_EDITOR $VISUAL $EDITOR gives me pico pico. How can I change these variables?
Masi
You can change them with export GIT_EDITOR=vim export VISUAL=vim export EDITOR=vim(If the variable are already exported, you can omit the ``export´´).
Jochen Walter
A: 

Since none of these answers are helping me:

Here is what the git docs are saying: http://www.kernel.org/pub/software/scm/git/docs/git-commit.html

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).

Here is the BASH man page excerpt on export (brackets are optional):

export [-fn] [name[=word]]

bentford