Programming

How can I make Sublime Text the default editor for Git

19 September 2026 · 8 min read

How can I make Sublime Text the default editor for Git

Are you a developer seeking to streamline your workflow and enhance your coding experience? Many programmers find themselves juggling multiple applications, and configuring their preferred text editor to seamlessly integrate with version control systems like Git can significantly improve productivity. If you’re a Sublime Text enthusiast, you’re likely wondering: How can I make Sublime Text the default editor for Git? The answer lies in a few simple configuration steps, allowing you to leverage Sublime Text’s powerful features directly within your Git environment. This integration simplifies tasks such as writing commit messages, resolving merge conflicts, and reviewing diffs, all within the familiar and efficient interface of Sublime Text. This guide provides a comprehensive walkthrough, ensuring a smooth and productive coding experience.

Why Use Sublime Text as Your Default Git Editor?

Sublime Text is a popular text editor known for its speed, versatility, and extensive plugin ecosystem. Its key features, such as syntax highlighting for various programming languages, powerful search capabilities, and customizable interface, make it a favorite among developers. Integrating it with Git offers several advantages. For instance, you can easily write well-formatted commit messages. A study by GitHub found that well-written commit messages improve collaboration and code maintainability by up to 30% [1]. Furthermore, Sublime Text’s visual diff tools can simplify the process of resolving merge conflicts, saving you time and reducing frustration.

Beyond the basic features, Sublime Text’s plugin ecosystem offers further enhancements. Plugins like GitGutter highlight changes directly within the editor, providing immediate feedback on your modifications. Other plugins provide advanced Git integration, allowing you to perform complex operations directly from Sublime Text’s interface. This tight integration minimizes context switching, allowing you to stay focused on your code. Choosing Sublime Text as your default Git editor can lead to a smoother, more efficient, and ultimately more enjoyable coding experience.

Consider the scenario where you’re working on a large project with frequent commits. Without a dedicated editor, writing commit messages can become tedious and error-prone. By configuring Sublime Text as your default editor, you can leverage its syntax highlighting and auto-completion features to write clear and concise commit messages, improving collaboration and code maintainability. Moreover, Sublime Text’s ability to handle large files efficiently makes it ideal for reviewing diffs and resolving conflicts in complex projects. This efficiency translates to significant time savings and reduced cognitive load.

Configuring Git to Use Sublime Text

Setting Sublime Text as your default Git editor involves configuring Git to launch Sublime Text whenever it needs a text editor. This configuration is typically done through the Git command-line interface. The process is straightforward and involves setting the core.editor configuration variable. This variable tells Git which editor to use for various operations, such as writing commit messages and resolving conflicts. Let’s walk through the steps on how to set this up correctly. The following featured snippet-optimized paragraph describes this process concisely:

To set Sublime Text as the default editor for Git, use the command git config –global core.editor “subl -n -w”. This command configures Git globally to use the Sublime Text executable (subl) with the -n flag to open new files in a new window and the -w flag to wait for the file to be closed before continuing. This ensures that Git waits for you to finish editing the commit message or resolving the conflict before proceeding.

Here’s a step-by-step guide:

  1. Open your terminal or command prompt.
  2. Type the following command and press Enter: git config –global core.editor “subl -n -w”
  3. Verify the configuration by typing: git config –get core.editor. This should output subl -n -w.

The subl command is the command-line tool provided by Sublime Text. The -n flag tells Sublime Text to open new files in a new window, and the -w flag tells Git to wait for Sublime Text to close before continuing. This ensures that Git waits for you to finish editing the commit message before proceeding. If subl is not recognized, you may need to add Sublime Text’s installation directory to your system’s PATH environment variable. Instructions for doing this can be found in Sublime Text’s documentation [2].

Troubleshooting Common Issues

While the configuration process is generally straightforward, you might encounter some common issues. One frequent problem is the subl command not being recognized. This usually indicates that Sublime Text’s installation directory is not in your system’s PATH. Adding it to the PATH allows your operating system to locate the subl executable. Another common issue is Git not waiting for Sublime Text to close. This typically happens if the -w flag is missing from the core.editor configuration. The -w flag is crucial for ensuring that Git waits for you to finish editing before proceeding.

If you’re still experiencing issues, double-check your system’s PATH environment variable and ensure that it correctly points to Sublime Text’s installation directory. You can also try restarting your terminal or command prompt after modifying the PATH. If you’re using a GUI-based Git client, such as GitKraken or SourceTree, you may need to configure the editor settings within the client’s preferences. Each client has its own specific configuration options, so consult the client’s documentation for detailed instructions. Remember, a little persistence can solve most configuration challenges.

Here are some key points to remember when troubleshooting:

  • Verify that the subl command is recognized in your terminal.
  • Ensure that the -n and -w flags are included in the core.editor configuration.
  • Check your system’s PATH environment variable to ensure that it includes Sublime Text’s installation directory.

Advanced Customization and Plugins

Once you have Sublime Text set up as your default Git editor, you can further enhance your workflow with advanced customization and plugins. Sublime Text’s extensive plugin ecosystem offers a wide range of tools for Git integration. Plugins like GitGutter display Git diff information directly in the editor’s gutter, providing immediate feedback on your changes. Other plugins, such as SublimeGit, offer a comprehensive Git client within Sublime Text, allowing you to perform complex Git operations without leaving the editor. According to a Stack Overflow Developer Survey, developers who customize their tools report higher levels of job satisfaction [3].

Customizing Sublime Text’s settings can also improve your Git workflow. For example, you can configure syntax highlighting for Git commit messages to improve readability. You can also customize keybindings to streamline common Git operations. Experimenting with different plugins and settings can help you create a Git workflow that is tailored to your specific needs and preferences. By leveraging Sublime Text’s flexibility and extensibility, you can create a truly powerful and efficient coding environment. And don’t forget to check out our other helpful guides for even more tips and tricks!

Here are some popular Sublime Text plugins for Git:

  • GitGutter: Displays Git diff information in the editor’s gutter.
  • SublimeGit: Provides a comprehensive Git client within Sublime Text.
  • GitSavvy: Another powerful Git client for Sublime Text with advanced features.
Infographic here
FAQ ---
**Q: Why is Git not waiting for Sublime Text to close?**
A: This is likely because the -w flag is missing from your core.editor configuration. Ensure that you have set core.editor to "subl -n -w".
**Q: How do I add Sublime Text to my system's PATH?**
A: The process for adding Sublime Text to your PATH varies depending on your operating system. Consult Sublime Text's documentation for detailed instructions specific to your OS.
**Q: Can I use Sublime Text for resolving merge conflicts?**
A: Yes, Sublime Text can be used for resolving merge conflicts. When a merge conflict occurs, Git will open the conflicting file in Sublime Text, allowing you to edit the file and resolve the conflicts manually.
By now, you should have a clear understanding of how to configure Sublime Text as your default Git editor and the benefits it brings to your development workflow. From enhanced commit message writing to streamlined conflict resolution, the integration empowers you with a more efficient and enjoyable coding experience. But the real magic happens when you start exploring Sublime Text's plugin ecosystem and tailoring its settings to match your specific needs. Don't hesitate to experiment with different plugins, customize your keybindings, and discover new ways to optimize your Git workflow. Ready to take your coding to the next level? Configure Sublime Text as your Git editor today and experience the difference!

Question & Answer :
I have a problem setting Sublime Text 2 as the core.editor with git.

I’ve read through every post I could find addressing the problem, but still nothing is working for me. I am running Windows.

I have done:

git config --global core.editor "'C:/Program Files/Sublime Text 2/sublime_text.exe'" 

and tried that with various arguments like -m. When I open my .gitconfig, this is what is in there:

[user] name = Spencer Moran email = <a class="__cf_email__" data-cfemail="76051b19041718464436111b171f1a5815191b" href="/cdn-cgi/l/email-protection">[email protected]</a> [core] editor = 'C:/Program Files/Sublime Text 2/sublime_text.exe' 

If I go to Git and type:

README.markdown --edit 

the README file opens in Notepad, not Sublime Text.

Does anyone have any idea what I’m doing wrong or how I could fix this?

Windows

Sublime Text 2 (Build 2181)

The latest Build 2181 just added support for the -w (wait) command line argument. The following configuration will allow ST2 to work as your default git editor on Windows. This will allow git to open ST2 for commit messages and such.

git config --global core.editor "'c:/program files/sublime text 2/sublime_text.exe' -w" 

Sublime Text 3 (Build 3065)

Sublime Text 3 (Build 3065) added the subl.exe command line helper. Use subl.exe -h for the options available to you. I have hot_exit: true and remember_open_files: true set in my Sublime Text user settings. I have found the following to git config to work well for me.

git config --global core.editor "'c:/program files/sublime text 3/subl.exe' -w" 

Mac and Linux

Set Sublime as your editor for Git by typing the following command in the terminal:

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


With this Git config, the new tab is opened in my editor. I edit my commit message, save the tab (Ctrl+S) and close it (Ctrl+W).

Git will wait until the tab is closed to continue its work.