Apple - Replaced /usr/bin/vim - now I get error messages

This is a known issue. From :help MacVim:

Note: Starting MacVim by creating a symlink to >
    .../MacVim.app/Contents/MacOS/Vim with 'ln -s' does not work.

I found a lot of people getting a string of E254 errors from using a symlink. See this ticket on the MacVim issue repository. The solution follows:

    Most likely this is because you have symlinked directly to
    the Vim binary, which Cocoa does not allow.  Please use an
    alias or the mvim shell script instead.

MacVim comes with a startup shell script, mvim. You can alias it to vim if you'd prefer to use it instead of the system vim. If you want to start vim in the terminal rather than as a gui application, set the alias to mvim -v. Add export EDITOR=vim to your ~/.bash_profile to make sure that any terminal applications are using the now-aliased vim. This should cover all your bases.


Changing something in /usr/bin is not the best way to go about things as Apple can just overwrite it again.

The errors are probably as @karmatic says but probably the best thing to do here is put the symbolic link in /usr/local/bin and make your shell have that in the path earlier than /usr/bin.

As far as I know no command line tool uses /usr/bin/vi directly (I use emacs so I would spot having to use vi) What they do is use the environment variable $EDITOR so set that to /usr/local/bin


I don't have any rep yet so I can't comment on michaelmichael's answer but based on his answer I edited the mvim wrapper script to add another case statement. So that if $name was vim it will add the -v option. I then symlinked /usr/local/bin/mvim to /usr/local/bin/vim.

47 # vimdiff, view, and ex mode
48 case "$name" in
49     vim)
50         opts="$opts -v"
51         ;;
52     *vimdiff)

This was all because in some cases I couldn't rely on EDITOR being set or on aliases but I could rely on /usr/local/bin being in PATH.

Tags:

Macvim