I would prefer to write my commit messages in Vim, but it is opening them in Emacs.
How do I configure Git to always use Vim? Note that I want to do this globally,
On Ubuntu and also Debian (thanks @MichielB) changing the default editor is also possible by running:
sudo update-alternatives --config editor
Which will prompt the following:
There are 4 choices for the alternative editor (providing /usr/bin/editor).
Selection Path Priority Status
------------------------------------------------------------
0 /bin/nano 40 auto mode
1 /bin/ed -100 manual mode
2 /bin/nano 40 manual mode
* 3 /usr/bin/vim.basic 30 manual mode
4 /usr/bin/vim.tiny 10 manual mode
Press enter to keep the current choice[*], or type selection number:
On macOS Big Sur (11.0) beta for TextMate: none of the environment variable options worked. (Set all three: GIT_EDITOR, VISUAL, and EDITOR.)
Finally set the global core.editor in git, and that worked:
git config --global core.editor "~/bin/mate -w"
When using git-review
I had to modify sequence.editor
value to be able to do interactive rebase (git rebase -i -p
):
git config --global sequence.editor "gvim" # or whatever your prefer
gvim
require: apt install vim-gtk
This opens Textmate editor in when you want to edit your commits. Requires textmate command line tools to be installed.
git config --global core.editor "mate -w"
For emacs users
.emacs
:
(server-start)
shellrc
:
export EDITOR=emacsclient
Just try EDITOR=vim git commit
.
Or you can set your EDITOR to vim by export EDITOR=vim
in your bashrc.