little cubes

Stop using Git's default text editor

Zach Posten - 2022 Mar 03

Use the text editor you're most comfortable with

Stop using Git's default text editor

Whether you installed Git yourself, or you're using the version that came pre-installed on your OS, the default text editor will be Vim. Too often people leave this default and struggle through learning an un-intuitive text editor while they're also trying to learn Git.

Even worse, some can't distinguish Git from Vim, thinking that they're one in the same; because for many, their first time running git commit is also the first time they've seen Vim. The confusion of the text editor becomes muddled together with the confusion of learning Git, so they turn to a Git GUI tool and immediately lose so much of the power behind Git.

There is a better way! And it's really easy!

You can tell git to use whatever text editor you prefer. Then, when you run git commit or git rebase -i, instead of Vim opening in the terminal, your chosen text editor will pop up for you! You then edit the file, save the file, and close that window of your text editor.

Done!  

Instructions

The details change slightly depending on the text editor you want to use. I will provide info for several common text editors here.

Using VS Code as your Git editor

  1. Open VS Code, open the command palette (cmd + shift + p), type code, and then select Shell Command: Install 'code' command in PATH.
    • This will allow you to run code from the command line to open directories or files.
  2. Then run:
1 git config --global core.editor "code --wait"

Using Sublime Text as your Git editor

1 git config --global core.editor "subl -n -w"

Using Webstorm/IntelliJ as your Git editor

  1. From the menu bar, choose Tools -> Create Command-line Launcher. Accept the default path.
  2. Then run:
1 git config --global core.editor “webstorm -w”

Using Notepad++ as your Git editor (Windows)

1 git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"