Vim – How to Make Settings Computer-Dependent in .vimrc

dependenciesoperating systemsvimvimrc

I share my VIM configuration file between several computers. However, I want some settings to be specific for certain computers.

For example, font sizes on the high-res laptop should be different to the low-res desktop. And more importantly, I want gVIM on Windows to behave more windowsy and MacVim on OSX to behave more maccy and gVIM on Linux to just behave like it always does. (That might be a strange sentiment, but I am very used to switch mental modes when switching OSes)

Is there a way to make a few settings in the .vimrc machine- or OS-dependent?

Best Answer

OS detection in .vimrc:

if has('win32')
    ......
elseif has('mac')
    ......
elseif has('unix')
    ......
endif
Related Question