When writing commit messages or editing merge commits and interactive rebasing an editor is used to accept the commit messages. By default this is nano on Ubuntu systems.
The simplest way to change the this is to use the following command to change the git configuration item.
git config --global core.editor "vim"The editor setting is actually controlled in a few different ways.
From the documentation from Git:
GIT_EDITORis the editor Git will launch when the user needs to edit some text (a commit message, for example). If unset,EDITORwill be used.
ENVIRONMENT AND CONFIGURATION VARIABLES
The editor used to edit the commit log message will be chosen from the
GIT_EDITORenvironment variable, thecore.editorconfiguration variable, theVISUALenvironment variable, or theEDITORenvironment variable (in that order).
The core.editor configuration variable will set this, but you can override this by setting GIT_EDITOR in your profile. The following will have the same effect as the first code example.
export GIT_EDITOR="vim"The VISUAL and EDITOR variables are standard environment variables used by many other systems so if you want to use Vim for everything then you can set the following options in your environment.
export VISUAL=vim
export EDITOR="$VISUAL"As a side note, some editors require a --wait flag to be set in order for them to work.
Sublime Text (on Mac):
export VISUAL="subl --wait"VS Code:
export VISUAL="code --wait"
Add new comment