Unable to change the default editor in terminal

2019-01-17 14:29发布

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'

8条回答
霸刀☆藐视天下
2楼-- · 2019-01-17 14:57

if you want vi to be your default history editor (which is why I'm here)

edit ~/.bashrc and add

set -o vi

anywhere in the file. Then all the lovely vi command history is available (esc k etc).

Sorry if this is slightly off topic, but my search landed me here....

查看更多
We Are One
3楼-- · 2019-01-17 15:03

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.

查看更多
登录 后发表回答