How to make Git use the editor of choice for commits?

Explanation

You can make Git use the editor of your choice for commits in the following ways. You can choose any one :

    • Set core.editor in your Git config: git config --global core.editor "vim"

Or you can do it like this :

    • Set the GIT_EDITOR environment variable: export GIT_EDITOR=vim

So if you are willing to set the editor for Git and also other programs, You can set the standardized VISUAL and EDITOR environment variables as shown below:

export VISUAL=vim
export EDITOR="$VISUAL"

 

Here you have to remember one thing that Setting both is not necessarily needed, but some programs may not use the more-correct VISUAL.

Also, there are some editors who require a --wait flag. Or they will open a blank page in the editor. Here is an example of that:


Sublime Text

export VISUAL="subl --wait"

VS Code

export VISUAL="code --wait"

 

Also read, What is the !! (not not) operator in JavaScript?

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *