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

前端 未结 7 651
庸人自扰
庸人自扰 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:45

    I could not edit previous answer by adding two character only:

    Here is correct one(passed on my macos 10.6 and default vim console version)

    if has("unix")
      let s:uname = system("uname")
      if s:uname == "Darwin\n"
        " Do Mac stuff here
      endif
    endif
    

    system("uname") will come up with a return character, which makes second if condition failed. Just a small fix to add "\n".

    0 讨论(0)
提交回复
热议问题