Make Vim Your Go-To Git Commit Editor
When you run git commit
, Git opens a text editor. By default, that editor is often nano
. Nano is actually pretty simple to use.
user@userver:~/linux$ git add new
user@userver:~/linux$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: new
Just press Ctrl + X to exit, then hit Y
to save your changes and you are out of the nano editor!
But I am guessing you are curious about Vim
. It is a powerful text editor that many developers love especially for how fast and efficient it can be once you get the hang of it.
In this post, I will show you how to:
-
Set Vim as your default Git editor
-
Understand why Vim can be a better choice for some workflows
-
Learn a few quick tips to make editing Git messages in Vim easier
Let’s dive in and make your Git experience a little smoother!
Set Vim as the Default Editor in Git
git config --global core.editor "vim"
That’s it! This tells Git to open Vim any time it needs you to type something in an editor (e.g., a commit message).