2

A long time ago, before I switched to vims, I used an editor for OS X known as TextMate. (Anyone remember that? ;)

Its command-line binary, mate, allowed for a mate -w flag, which would block the command-line binary exiting until the file was saved, and closed. This allowed for using mate -w as the editor for git commit-messages and similar.

Trying to do similar with MacVim (or gVim) doesn't work out; as the mvim helper closes as soon as MacVim is launched (or as soon as the file is opened). This results in a “your message was empty,” or similar other error, from whichever program invoked the $EDITOR: as far as the program knows, the ‘editor’ (the mvim helper-binary) has exited, but the file it's provided to edit is still empty.

Is there some command, configuration setting, or hack that I could use to ensure the command-line mvim helper (or whatever alternative alias or script you come up with for me) doesn't exit until the opened files have been saved and closed in MacVim?

7

You probably want the -f command line option (meaning “stay in foreground”; see :help -f). You can usually incorporate it directly into your EDITOR value (or that of VISUAL, GIT_EDITOR, or Git’s core.editor, etc.):

EDITOR='mvim -f'; export EDITOR

This option is not specific to mvim; it should also work with gvim (i.e. any GUI vim).

1

Did you know you can run MacVim in your terminal emulator?

$ mvim -v filename
0

You can force mvim to block the terminal adding: -f or --nofork

-f or --nofork Foreground: Don't fork when starting GUI

So just add this to your profile:

export EDITOR="mvim -f"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.