Course contentsShow
← Git & GitHub
Lesson 8 of 961. Foundations of Version ControlFree lesson

Selecting a Default Text Editor for Git

You will set your preferred code editor as the default interface for writing commit messages and handling configuration tasks within Git.

In this lesson, you will learn how to configure Git to open your preferred code editor whenever you need to write commit messages or handle configuration tasks.

Why Do You Need a Default Editor?

When you perform certain Git actions—like creating a commit without specifying a message—Git needs a place for you to type that message. By default, Git might open a cryptic, terminal-based editor called "Vim," which can be very confusing for beginners. To make your life easier, you can tell Git to use a friendly editor you already know, such as VS Code, Sublime Text, or Notepad++.

Setting Your Editor

To set your global default, you use the git config command. You simply tell Git which command launches your editor.

If you are using VS Code, the command to launch it from the terminal is code. You can tell Git to use it by running this in your terminal:

git config --global core.editor "code --wait"

Note: The --wait flag is important here; it tells Git to pause and wait for you to close the editor window before it finishes saving your commit message.

Checking Your Configuration

If you ever want to see which editor you have currently set, you can view your configuration settings at any time by running:

git config --global --list

Look for the core.editor line in the output. If it isn’t there, Git is likely using its system default.

By setting this now, you ensure that every time Git needs your input, a familiar interface will pop up. This turns what could be a frustrating terminal experience into a seamless part of your workflow, allowing you to focus on your code rather than struggling with a text editor you aren't familiar with.

Key Takeaway: Setting your global core.editor allows you to write commit messages in a comfortable environment, making your interaction with Git much more intuitive.