Settings default font in gvim

允我心安 提交于 2019-11-29 07:12:46

问题


I'm using gvim (vim -g). I want to set default font to be Monaco.

Here is the content of my .vimrc

if has("gui_running")
    if has("gui_gtk2")
         set guifont=Monaco\ New\ 11
       elseif has("gui_photon")
         set guifont=Monaco\ New:s11
       elseif has("gui_kde")
         set guifont=Monaco\ New/11/-1/5/50/0/0/0/1/0
       elseif has("x11")
         "set guifont=-*-courier-medium-r-normal-*-*-180-*-*-m-*-*
         set guifont=Monaco:h11:cDEFAULT

       else
         set guifont=Monaco:h11:cDEFAULT
     endif
  endif

When I start gvim the font is not Monaco


回答1:


The easiest way of setting the 'guifont' is simply not bothering with the exact font string at all.

Use a friendly dialog to set it instead:

:set guifont=*

This pops up a dialog where you can select your preferred font.

Once you have set it, you can query the setting again with

:set guifont?

and put that string in your vimrc. On my machine this returns Monaco:h12 for Monaco at 12pt. Make the change at the appropriate place in your block, or, if you have no idea what you're doing, simply replace the whole block with

if has("gui_running")
  set guifont=Monaco:h12
endif



回答2:


set guifont=Font\ Name\ Size

Replace the spaces by '\ '



来源:https://stackoverflow.com/questions/16882696/settings-default-font-in-gvim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!