how do I detect OS X in my .vimrc file, so certain configurations will only apply to OS X?

前端 未结 7 666
庸人自扰
庸人自扰 2020-12-12 15:18

I use my .vimrc file on my laptop (OS X) and several servers (Solaris & Linux), and could hypothetically someday use it on a Windows box. I know how to detect unix gene

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 15:30

    homebrew vim and MacVim returns true for has('mac'), however so does has('unix'). so to have it work across all unix platforms, a possible solution is:

    if has('unix')
      if has('mac')       " osx
        set guifont=...
      else                " linux, bsd, etc
        set guifont=...
      endif
    elseif has('win32') || has('win64')
      set guifont=...
    endif
    

    on the other hand, as of el capitan, the system vim returns false for has('mac'), and uname snooping is probably the way to go. it's an ancient version, never used it.

提交回复
热议问题