44
17
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?
A very late answer, but yes, has('mac') triggers in OSX for me. – Diablo-D3 – 2015-03-28T09:13:00.250
1I've tested vim 1) that comes with OS X, and 2) that I installed via Gentoo Prefix (something similar to Homebrew), and 3) that comes from MacVim. Only the one comes from MacVim will correctly return true for
has("mac")
. My guess is that they used some patch that actually make the feature test work. If you do rely onhas("mac")
test, do some test to make sure it's supported on your vim. – yegle – 2015-10-10T04:26:28.830Note that you have to test
has('mac')
andhas('unix')
in the order above, because a Mac also has unix! – Giles Gardam – 2017-05-27T13:40:05.4434Also useful:
has('gui_running')
if you need to differentiate between tty mode and GUI mode. – Chris Johnsen – 2010-10-01T13:20:08.35010The has() function tests the presence of Vim features. There is no 'linux' feature. The proper argument is 'unix'. Also, the proper argument for OS-X is 'macunix'. There is also a 'mac' feature, but I don't know whether
has('mac')
is true for all Macs or just pre-OS-X Macs. See:help feature-list
for the full list. – garyjohn – 2010-10-01T15:14:44.1401Yes,
has('unix')
. My mistake. – Casual Coder – 2010-10-01T17:14:16.277