views:

1321

answers:

3

How do I use Notepad++ (or any other editor besides vim) with msysgit?

I tried all of the following to no avail:

git config --global core.editor C:\Program Files\Notepad++\notepad++.exe

git config --global core.editor "C:\Program Files\Notepad++\notepad++.exe"

git config --global core.editor C:/Program Files/Notepad++/notepad++.exe

git config --global core.editor C:\\Program Files\\Notepad++\\notepad++.exe
+7  A: 

The following:

C:\prog\git>git config --global core.editor C:/prog/git/npp.sh

C:/prog/git/npp.sh:
#!/bin/sh
"c:/Program Files/Notepad++/notepad++.exe" -multiInst "$*"

does work. Those commands are interpreted as shell script, hence the idea to wrap any windows set of commands in a sh script.

More details on the SO question How can I set up an editor to work with Git on Windows?

Note the -multiInst' option, for ensuring a new instance of notepad++ for each call from Git.


If you want to place the script 'npp.sh' in a path with spaces (as in 'c:\program files\...,'), you have three options:

  • either try to quote the path (single or double quotes), as in

    git config --global core.editor 'C:/program files/git/npp.sh'

  • or try the shortname notation (not fool-proofed)

    git config --global core.editor C:/progra~1/git/npp.sh

  • or (my favorite) place npp.sh in a directory part of your %PATH% environment variable. You would not have then to specify any path for the script.

    git config --global core.editor npp.sh

VonC
I got this to work by placing npp.sh in the root of my drive (ie - C:/npp.sh). Any time I try to target a folder with spaces (ie - D:/Program Files (x86)/Git/npp.sh) in it it fails, what's the proper way to escape spaces and/or get this to work?
PHLAK
put quotes around it. See how he has quotes around the entire thing in his example?
Fred
A: 

This works for me:

git config --global core.editor C:/Progra~1/Notepad++/notepad++.exe

Tim Scott
+12  A: 
git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
zumalifeguard
This is the simplest one
Ian1971