How can I make Sublime Text the default editor for Git?
default, editor, git, git-config, sublimetext
Solution
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.
Problem
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 = smoran02@gmail.com [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?