VIM: has('macunix') or has('mac') do not work

macos, vim

Solution

I agree with Randy Morris, use MacVim's bundled CLI executable.

However, here are a few lines from my `~/.vimrc`:

let os=substitute(system('uname'), '\n', '', '')
if os == 'Darwin' || os == 'Mac'
    set guifont=Inconsolata-dz:h12
    " more...
elseif os == 'Linux'
    set guifont=Inconsolata-dz\ Medium\ 10
    " more...
endif

On Mac OS X, `$ uname` returns `Darwin` when in X11/XQuartz and `Mac` otherwise.

Problem

I've moved from using MacVim to using vim in terminal on my MacOs Lion and I've realized that both: ``` has('macunix') has('mac') ``` return false instead of true (they work fine within MacVim). This is an issue because I use the same .vimrc on my Mac and on my Archlinux linode and need to set specific options based on the OS. The only solution I could dig so far is to use the hostname() function to get the machine name and map it on a specific OS but it is not as elegant as being able to check the OS itself. Anybody knows why the has('...') commands don't work as documented?

Original source