Coffee Talk: Java, News, Stories and Opinions

May 3 2018   9:50PM GMT

How to set Notepad++ as the default Git editor for commits instead of Vim

cameronmcnz Cameron McKenzie Profile: cameronmcnz


For the most part, developers who are new to the Git tool don’t have too much of a problem mastering the five basic git commands every beginner should learn. But one speed-bump that does tend to trip up new users is the fact that the Git editor defaults to Vim. For those with a Windows background, figuring out how to add a comment, save the entry and then exit the Vim Git editor can be frustrating, if not a little scary.

Changing away from Vim as the default Git text editor

Notepad++ is often preferred over Vim as the default Git editor for commit text.

Changing the Git editor to Notepad++

Fortunately, it’s not that difficult to change the default Git editor to a text editor of your choosing, be it Notepad, EditPad or my personal favorite, Notepad++.  All you have to do is issue a git config command and specify the core editor of your choice. The config command to change the default Git editor to Notepad++ is as follows:

gitbeginner@devops MINGW32 /c/ change git/ default editor
$ git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

It should be noted that I issued this command on a Windows 32-bit machine. Obviously, on an x64 machine, Notepad++ would be found under the Program Files (x86) directory. The bottom line is that when you run this command, make sure you provide the correct location of your text editor of choice.

This change to the default Git text editor was specified to take place at the global Git scope, so the change can be inspected by opening the .gitconfig file found under the user’s home directory. Upon inspection, you will note that a new core heading has been added to the Git configuration file and the editor property has been set to Notepad++:

Making Notepad++ the default Git text editor

How to change the default Git editor to Notepad++ in the global .gitconfig file



  editor = 'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin

Using Notepad++ as the Git editor

As far as the switches after the listing of the executable, those are all Notepad++ specific and have nothing to do with Git. These popular switches ensure that a new Notepad window is displayed, rather than just adding a new tab to an existing Notepad++ instance that might already be running. The switches also ensure that no plugins are loaded into Notepad++, which might make loading Notepad++ faster while avoiding any problems with misconfigured plugins. The -nosession switch tells Notepad++ not to bring up any files from previous sessions, ensuring that the current commit is the only thing the text editor displays.

The next time you issue a git commit without specifying a commit message, Notepad++ will pop up. Just add a message, click save and close the window. The message you typed in will then become part of the history of the git branch upon which you are working.

Further improve your DevOps tools knowledge

Mastered Git? The next step in your DevOps journey is mastering Jenkins CI. Here are some great Jenkins tutorials that will take you from beginner to expert.

Step 1 — How to download, configure and install Jenkins tutorial

Step 2 — Create your first Jenkins freestyle build job example

Step 3 — Pull from the Jenkins environment variables list in your shell scripts

Step 4 — Fix common Jenkins plugin installation errors

Step 5 — Add String and Boolean Jenkins parameters to your builds

Step 6 — Start pulling from GitHub with the Jenkins Git plugin

Step 7 — What happens when you git reset hard and push?

Step 8 — Get a handle on the  Jenkins vs. Maven debate

Step 9 — Learn how to do a hard git reset on a commit


 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: