Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to change the default editor in the terminal

Tags:

bash

vim

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 to be my default editor?

The following code does not work in file .bashrc:

export EDITOR='vim'
like image 990
Léo Léopold Hertz 준영 Avatar asked Mar 15 '09 00:03

Léo Léopold Hertz 준영


People also ask

How do I change the default text editor in Terminal?

To change your default text editor, you can use git config (if git is installed on your computer already). Open the terminal and use the table below to change your default text editor. IMPORTANT: in order to change your default text editor, the text editor of your choice needs to be already installed on your computer!

How do I change the editor in Mac terminal?

In the Terminal app on your Mac, invoke a command-line editor by typing the name of the editor, followed by a space and then the name of the file you want to open. If you want to create a new file, type the editor name, followed by a space and the pathname of the file.


3 Answers

Adding

export EDITOR=vim

to your .bashrc file should really do the trick. (Quotes aren't necessary there 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 file .bashrc for the modification to take effect.

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

I haven't used Git, but the documentation 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.

like image 149
Jochen Walter Avatar answered Oct 21 '22 17:10

Jochen Walter


You can use the Git configuration option core.editor to set the editor of your liking, e.g., nano:

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

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

...
[user]
  name = Your Name
  email = [email protected]
[core]
  editor = nano
...
like image 21
4levels Avatar answered Oct 21 '22 17:10

4levels


Check this command:

sudo update-alternatives --config editor
like image 2
Grzegorz Brzęczyszczykiewicz Avatar answered Oct 21 '22 15:10

Grzegorz Brzęczyszczykiewicz