3

I know this question has been asked and answered more than once. But I tried at least ten different ways of doing it suggested by the answers and none of them work for me. I always get nano as the editor when I do

git commit

(This would not be such a big problem if I could cut and paste into nano, but it can't be done)

Just as an example, here are the lines in my .gitconfig file, but please bear in mind I tried many variations of this:

[core]
    editor = 'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin
Soldalma
  • 4,636
  • 3
  • 25
  • 38
  • Does this answer your question? [How can I set up an editor to work with Git on Windows?](https://stackoverflow.com/questions/10564/how-can-i-set-up-an-editor-to-work-with-git-on-windows) – Michael Freidgeim Jun 15 '21 at 20:56

3 Answers3

4

This should work:

[core]
    editor = \"C:/Program Files (x86)/notepad++/notepad++.exe\" -multiInst -notabbar -nosession -noPlugin

or from command line:

git config --global core.editor '"C:/Program Files/Notepad++/notepad++.exe" -multiInst -notabbar -nosession -noPlugin'

PS: You could also install GitExtensions that will help you set it...

Philippe
  • 28,207
  • 6
  • 54
  • 78
  • @Thanks for the suggestion, but that does not work either. I installed GitExtensions, which is for Visual Studio. I am not using Git from within Visual Studio. – Soldalma Sep 18 '18 at 16:36
  • Gitextensions is not linked to visual Studio. Does it put the setting well? . Put notepad directory in the PATH, that way you could remove the path from the config. And what is the error returned by git? – Philippe Sep 18 '18 at 18:29
  • I had downloaded GitExtensionsVSIX.vsix, that is why I thought it was for Visual Studio. Now I downloaded a zip file that contains what looks like a Visual Studio solution. There is a GitExtensions.sln file among many other files and folders. But I do not know what to do with it. Should I compile an executable using Visual Studio? On your last question, when I try to commit and get nano instead of notepad++ there are no error messages. All that happens is that nano starts. – Soldalma Sep 19 '18 at 04:54
  • You should have 2 config key. Use `git config --list --show-origin | grep editor` to diagnostic why. That's the `.msi` file (it's the extension name of installers on Windows) of GitExtensions that you should download – Philippe Sep 19 '18 at 10:43
4

It isn't elegant but this worked for me (enclose double-quotes with single-quotes):

git config --global core.editor '"C:/Program Files/Notepad++/notepad++.exe"'
  • The key to this is the nested quotation marks. Doesn't matter whether single quotes are the outer set or inner, you just need to have them nested. – ThatBlairGuy May 28 '19 at 16:39
2

After unsuccessfully trying all the suggestions mentioned earlier, finally

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

worked for me. If Notepad++ installation is on Program Files (x86) the command should be

git config --replace-all --global core.editor "'C:\\Program Files (x86)\\Notepad++\\notepad++.exe'"
Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170
axuno
  • 581
  • 4
  • 15