Vim script check running platform
i manage to answer my own question, for comparing string in vimscript we should use =~
instead of ==
. The reverse one is !~
So edit this line if s:uname == "Darwin"
to if s:uname =~ "Darwin"
to make this little script work.
I rewrite this as function:
function! GetRunningOS()
if has("win32")
return "win"
endif
if has("unix")
if system('uname')=~'Darwin'
return "mac"
else
return "linux"
endif
endif
endfunction
let os=GetRunningOS()
In case, someone interest in my .vimrc
, check my dotFiles