Sunday, December 15, 2013

gvim font style and size

Put this in your .gvimrc file:

if has("gui_running")
  if has("gui_gtk2")
    set guifont=Inconsolata\ 16
  elseif has("gui_macvim")
    set guifont=Menlo\ Regular:h18
  elseif has("gui_win32")
    set guifont=Consolas:h11:cANSI
  endif
endif

This sets the font style and size depending on which environment you are running.  For example, I am running Mac OSX so my font is set to "Menlo Regular:h18".

Select your preferred font by looking at Edit | Font | Show Fonts
To reveal what that means to gvim, run this within gvim:

:set gfn?

For example, if I use the graphical menu to select "English Andale Mono | Regular | 24", the command "set gfn?" would reveal "guifont=Andale Mono:h24"

With that knowledge, we can craft what font we need to provide in the .gvimrc file from above.  Escape spaces with a backslash, so we get:

Andale\ Mono:h24

So my .gvimrc script line would read:

set guifont=Andale\ Mono:h24


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.