Unable to change the default editor in the terminal Unable to change the default editor in the terminal bash bash

Unable to change the default editor in the terminal


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 $EDITORgit config --get-all core.editor

For me,

export VISUAL=vim

solved the problem.


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 = your@email.address[core]  editor = nano...


Check this command:

sudo update-alternatives --config editor