tags:

views:

97

answers:

2

What the title says. I can think of some hackish ways to do it, but is there a correct way to do this?

+2  A: 

If you are sure you will use Unix-like operating system, you can use

let os = substitute(system('uname'), "\n", "", "")
if os == "SunOS"
" Do Sun-specific stuff.
...
elseif os == "Linux"
" Do Linux-specific stuff.
...
endif

You can anyway use the has() command to check if some feature is supported, for more information look

:help has()
Martín Fixman
+3  A: 

To check for Windows, most scripts I have seen use the following:

let s:win = has("win16") || has("win32") || has("win64")

If none of these are defined, then it is a non-windows system and you can try the uname suggestion by Martín Fixman.

Tim Henigan