On 13/11/08 02:55, 703designs wrote:
> How can I detect my current platform in Vim? I share my configuration
> across platforms, and I need to set the font selectively:
>
> I use courier on Windows, and Dejavu Sans on all other platforms.
>
> Thanks,
> Thomas
Well, the key here is the has() function.
For a quick and dirty test, use
if has('unix')
" unix-like platform (including Cygwin)
else
" probably Windows
endif
For the 'guifont' option, however, you need to take care of the five
different incompatible formats used by various versions of Vim:
if has('gui')
" we use has('gui') rather than has('gui_running') here
" so it will work even if we start Console Vim first
" then run :gui manually (which is only possible on Unix)
if has('gui_gtk2')
set gfn=DejaVu\ Sans\ Mono\ 11
elseif has('gui_photon')
set gfn=DejaVu\ Sans\ Mono:s11
elseif has('gui_kde')
" the obsolete kvim
" just make sure it works correctly if it hits our vimrc
set gfn=DejaVu\ Sans\ Mono/11/-1/5/50/0/0/0/1/0
elseif has('x11')
" I'm guessing the following (other-X11 including GTK1)
" please check, and correct if necessary.
" On GTK1 (and maybe some others) you can use :set gfn=*
" Replace by asterisks like here
" to make it a little more general:
set gfn=-*-dejavu-medium-r-normal-*-*-110-*-*-m-*-*
" add another elseif here
" if you want DejaVu on mac-without-x11
else
" not x11 (probably Windows)
set gfn=Courier_New:h11:cDEFAULT
endif
endif
In all cases the first or only number is the size (use, of course, a
larger number for larger type, a smaller number for smaller type).
See http://vim.wikia.org/wiki/Setting_the_font_in_the_GUI
Best regards,
Tony.
--
Hackers do it with fewer instructions.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---