11

When using vim as my default editor, I (occasionally) accidentally pull up search (e.g. via /wq instead of :wq). Once I do, I escape out of search, and then exit correctly via :wq. However, when that happens, I see the following error message:

 hint: Waiting for your editor to close the file... error: There was a problem with the editor 'vi'.
 Please supply the message using either -m or -F option.

I'm trying to understand why vi is not exiting correctly, or how I can fix it to exit correctly even after a failed search.

I am using macOS High Sierra.

 VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2017 18:37:46)
 Included patches: 1-503, 505-680, 682-1283

Steps to reproduce:

 > git commit
 vim> i
 vim> My Commit Message
 vim> <Esc>
 vim> /wq
 vim> <Esc>
 vim> :wq

Thanks for the help.

hayesgm
  • 213
  • 2
  • 6
  • You shouldn't need the second ESC there. You say "I escape out of search" in the question text too - what state do you find Vi in after the /wq, what happens if you press :wq without the second ESC? – Sundar R Jun 06 '18 at 20:38
  • Good point, though the error still persists without the extra escape. – hayesgm Jun 15 '18 at 18:48
  • You may want to change the config to vi instead of vim – kawerewagaba May 23 '19 at 20:26

2 Answers2

12

It is possible that you have EDITOR left unset or to its default value of vi. Try making vim your editor. Although both vi and vim are the same executable in mac, I guess, vim behaves in a minimalist way when invoked as vi than vim.

git config --global core.editor /usr/bin/vim

Lakshman Kumar
  • 170
  • 1
  • 4
  • Great-- you're right that I did not have a default editor set. When I set the editor to usr/bin/vim it works as expected, and if I change it back to /usr/bin/vi it fails like above. Thanks for the help! – hayesgm Jun 15 '18 at 18:50
  • 1
    Wow, never thought that invoking Vim as vi would cause this kind of problems. Thank you! – Spidey Aug 20 '19 at 12:47
0

In my experience using the graphical gvim, I have to set git config --global core.editor "gvim -f" to make sure it properly waits for the editor to close. The -f option is also available for vi and vim. Try this if git is having trouble waiting for the editor to close.