I am trying to set the editor as the standard Notepad or even the Vim. However Git keeps showing me this message when I run git commit
:
> hint: Waiting for your editor to close the file... error: cannot spawn
> notepad++.exe: No such file or directory
I uninstalled the current git version I had installed and installed the new version Git-2.36.1-64-bit however the error persists (I already did it for the second time: this time choosing Vim instead of Notepad, with no success... always the same notepad++ error message shown).
I tried to find any old git config files that may have notepad++ setted up but I didn't find any. At %userprofile% folder there is the file with no editor setted. At the installation folder, under /etc also there is no editor setted. I already reboot the computer (even between instalations) but always got the same message.
This may come from an old installation that used to had notepad++ as default editor, but I re-installed it again twice choosing different editors and nothing changes.
Running git config --list
brings no core.editor setting.
I also already ran the command git config core.editor
with the correct path of the notepad.exe and nothing happens (even with the --global option).
I also checked under the "Program Data" folder, but the git config file there also doesn't have any editor setted.
I ran out of options, any help will be appreciated
In your particular case the culprit here was that something (not sure what the "something" was / is) had set GIT_EDITOR
in your environment. Using whatever command you need to unset the variable solved the problem.
Note that when Git goes to fire up an editor, it generally uses the first value from the following sequence of items, where $
indicates an environment variable and the lack of a dollar sign indicates a git config --get
setting (git config --get
can both get the setting and report whether it exists, and Git uses the latter internally):
$GIT_EDITOR
core.editor
$VISUAL
$EDITOR
If none of these succeed, Git falls back on the compiled-in-default.
(When using git rebase
, Git adds $GIT_SEQUENCE_EDITOR
and sequence.editor
in to the front of the list before invoking any editor on the series of pick
and other commands in the interactive rebase command sheet. This means you can write a script that uses interactive rebase, but doesn't open the regular editor on the pick
command-sheet, yet still opens the regular Git editor on any to-be-edited commits.)
The command-line invocation:
git var GIT_EDITOR
will obtain and print out the name of the editor Git is programmed to use. In my case that's vim
so git var GIT_EDITOR
prints vim
, but the command-line sequence:
(export GIT_EDITOR=example; git var GIT_EDITOR)
prints example
instead since my shell set the environment variable GIT_EDITOR
temporarily for the duration of that command.