Search code examples
macosvimmacvim

How can I use mvim to edit my crontab on Mac OS X (10.6.6)


mvim is installed in /usr/local/bin/ but can not be used as either EDITOR or VISUAL:

$ mvim -f # works as expected

$ EDITOR="/usr/local/bin/mvim -f" crontab -e
crontab: /usr/local/bin/mvim -f: No such file or directory
crontab: "/usr/local/bin/mvim -f" exited with status 1

I tried single quotes and using VISUAL instead of EDITOR. Same result. I also tried googling, but apparently the -f flag works just fine for everybody else.

I use Mac OS 10.6.6 and zsh, but the problem is the same in bash.


Solution

  • The problem is crontab expects to be able to run a program called "/usr/local/bin/mvim -f" if you supply that in the EDITOR environment variable.

    To get around that, you could write a short shell script. For example, call this one mvimf:

    #!/bin/bash
    /usr/local/bin/mvim -f "$@"
    

    Then you can run: EDITOR=/usr/local/bin/mvimf crontab -e