The first time I tried to do git commit on msysgit with no commit message (no –m switch), it opened up Vim so that I could write my commit message. Luckily for me I’d read enough Vim jokes on Twitter to know that :q or :q! would get me out. But there is no way I’d be able to actually write a commit message, save and quit in Vim (that’d probably take about 3 weeks of studying the documentation). Much easier to change the editor for git to Notepad++ or some other more familiar text editor.
The first step is to create a bat file (I called mine npp.bat) with the path to Notepad++ and the appropriate switches:
#!/bin/sh "C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -notabbar -nosession -noPlugin "$*"
This opens a new instance of Notepad++ with no sessions or tabs or plugins which is what I want when writing a commit message. Place the bat file in the git subdirectory of msysgit (c:\msysgit\git on my system) and then set the core.editor variable in git config:
git config --global core.editor c:/msysgit/git/npp.bat
See this answer on Stackoverflow for more variations on this.
The next step is to get Notepad++ to work from the command line. I want to be able to write:
and Notepad++ should open the .bashrc file. This is actually nothing to do with msysgit and involves replacing the default notepad application with Notepad++ in Windows. And the easiest way is to use a program called Notepad Replacer. Install this and voila, it now works. If you ever want to revert to the default notepad then just uninstall Notepad Replacer.
The other option is create a script file just like the npp.bat file but without the switches and name it npp with no extension and place it in the bin folder. Now I can write:
and it opens the file in Notepad++. This approach also works for any third party editor such as Word or Excel.
EDIT: An alternative way to achieve the same result is to install Gitpad to change the default editor to Notepad (or the default text editor).
- Git for Windows tip: Setting shell aliases with msysgit (danlimerick.wordpress.com)