Mac – Replaced /usr/bin/vim – now I get error messages

macvim

I tried to upgrade from the default vim install on Mac OS X (vim 7.2) to the one used by MacVim (vim 7.3) by creating a symlink:

ln -s /Applications/MacVim.app/Contents/MacOS/Vim /usr/bin/vim 

However, now I get the following error messages:

sk@supernova:~/ > /usr/bin/vim
E254: Cannot allocate color Red
E254: Cannot allocate color White
E254: Cannot allocate color Blue
E254: Cannot allocate color Red
E254: Cannot allocate color Grey
E254: Cannot allocate color Blue
E254: Cannot allocate color Brown
E254: Cannot allocate color SeaGreen
E254: Cannot allocate color SeaGreen
E254: Cannot allocate color Yellow
E254: Cannot allocate color Red
E254: Cannot allocate color Blue
E254: Cannot allocate color Magenta
E254: Cannot allocate color DarkCyan
E254: Cannot allocate color LightMagenta
E254: Cannot allocate color Grey
E254: Cannot allocate color Blue
E254: Cannot allocate color Magenta
E254: Cannot allocate color Red
E254: Cannot allocate color Yellow
E254: Cannot allocate color Black
E254: Cannot allocate color LightGrey
E254: Cannot allocate color DarkBlue
E254: Cannot allocate color Grey
E254: Cannot allocate color DarkBlue
E254: Cannot allocate color Grey
E254: Cannot allocate color DarkBlue
E254: Cannot allocate color LightGrey
E254: Cannot allocate color LightBlue
E254: Cannot allocate color LightMagenta
E254: Cannot allocate color Blue
E254: Cannot allocate color LightCyan
E254: Cannot allocate color LightGrey
E254: Cannot allocate color Grey90
E254: Cannot allocate color Grey90
E254: Cannot allocate color LightRed
E254: Cannot allocate color DarkGrey
E254: Cannot allocate color LightGrey
E254: Cannot allocate color Cyan
Error detected while processing /Users/sk/.vimrc:
line    1:
E185: Cannot find color scheme desert
Press ENTER or type command to continue

Anyone knows how to fix this? If I run just vim or /Applications/MacVim.app/Contents/MacOS/Vim directly I don't get the error messages. Only if /usr/local/bin/vim gets called. Either directly or via another command line application.


Just if someone comments that I could have simply created an alias, I actually did that before

alias vim=/Applications/MacVim.app/Contents/MacOS/vim

however, some other command line tools were still using /usr/bin/vim.

Best Answer

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.