Nat Ritmeyer has given the right solution. I will give you the cause.
As Steve Tooke explained, hiding your ~/.vimrc
or explicitly telling git
to use the complete path to vim
solves the problem. However, he ends with "I’d still like to get to the root of the problem".
Try this:
- Start a
git commit
to get yourself into a vim
editor.
- Hit
<CTRL> + Z
to stop the process and drop back to the TTY
Do a ps
and notice for your TTY (whose number you get with the tty
command) there is something like...
$ tty
/dev/ttys005
$ ps
PID TTY TIME CMD
17547 ttys005 0:00.15 -bash
65126 ttys005 0:00.02 git commit
65127 ttys005 0:00.10 vi .git/COMMIT_EDITMSG
$ which vi
/usr/bin/vi
$ ll /usr/bin/vi
lrwxr-xr-x 1 root wheel 3 Oct 3 17:40 /usr/bin/vi -> vim
$ jobs
[1]+ Stopped git commit
Get back to your vim process with fg %1
(or what ever stopped job number your git commit
is listed as).
What that shell output tells us is...
- I was using ttys005
- On the TTY
bash
called git
and git
called vi
- The full path of
vi
is /usr/bin/vi
- The
vi
command is a symlink to vim
- Calling
<CTRL> + Z
stopped the git commit
command and it was #1 in the job stack.
So, vi is the same command as vim?!?! Yes, but vim
notices that its argv[0]
was vi
and runs in compatible mode. This can cause problems depending on what is in your .vimrc
.
The best solution is to tell git to use vim, but I suggest you don't assume that your vim path is the same as everyone elses (maybe you installed via brew install vim
)
git config --global core.editor $(which vim)