From 96cdecffd34823a1d95dc1016dcf1c1766297bf1 Mon Sep 17 00:00:00 2001 From: David Boyd Date: Tue, 1 Jan 2019 16:38:02 +0000 Subject: [PATCH] Update docs for changing default git text editor (#25414) Previous docs only mentioned setting Atom as the default editor, updated to include sublime, vs code and notepad++; along with the app specific command line args. Also included is a sample command should you wish to test your updated git editor config --- guide/english/git/index.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/guide/english/git/index.md b/guide/english/git/index.md index c039e15223..e2460efc9d 100644 --- a/guide/english/git/index.md +++ b/guide/english/git/index.md @@ -62,10 +62,41 @@ git config --global user.email "myemail@example.com" ``` #### Change Your Text Editor -Git automatically uses your default text editor, but you can change this. Here's an example to use the Atom editor instead (the `--wait` option tells the shell to wait for the text editor so you can do your work in it before the program moves on): +Git automatically uses your default text editor (usually Vi or Vim) when you are prompted to edit a message (e.g. when amending a commit). You can change this by setting the `core.editor` in your Git Config. Below are examples for some popular editors: + +##### Edit using Atom + ```shell git config --global core.editor "atom --wait" ``` +The `--wait` option tells the shell to wait for the text editor to close before returning, therefore you can make your changes in the editor before git applies your message. + +##### Edit using VS Code + +```shell +git config --global core.editor "code --new-window --wait" +``` +The `--new-window` option tells VS Code to open the message in a new window that you can safely close when done. + +##### Edit using Sublime Text + +```shell +git config --global core.editor "subl -n -w" +``` + +##### Edit using Notepad++ (Windows) + +```shell +git config core.editor "'C:\Program Files (x86)\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin" +``` +Omit ` (x86)` from the path if the 64-bit version of notepad++ is installed. + +##### Launching your editor +After setting your `core.editor` you may wish to test to make sure it is configured correctly. Running the below command will launch the current config in your editor of choice: + +```shell +git config --edit +``` #### Add Color to Git Output You can configure your shell to add color to Git output with this command: