什么是适合C/C++编程的好的gvim guifont?

5

我正在尝试为gvim寻找最佳字体以编写C/C++代码。

我目前在~/.gvimrc中有以下设置,但我不喜欢它:

if has("gui_gtk2")
    set guifont=MiscFixed\ 11
else
    set guifont=-misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-1
endif
set columns=80 lines=50
set guioptions-=T "hide toolbar

"Try to load happy hacking teal colour scheme
"I copy this to ~/.vim/colors/hhteal.vim
silent! colorscheme hhteal
if exists("colors_name") == 0
    "Otherwise modify the defaults appropriately

    "background set to dark in .vimrc
    "So pick appropriate defaults.
    hi Normal     guifg=gray guibg=black
    hi Visual     gui=none guifg=black guibg=yellow

    "The following removes bold from all highlighting
    "as this is usually rendered badly for me. Note this
    "is not done in .vimrc because bold usually makes
    "the colour brighter on terminals and most terminals
    "allow one to keep the new colour while turning off
    "the actual bolding.

    " Steve Hall wrote this function for me on vim@vim.org
    " See :help attr-list for possible attrs to pass
    function! Highlight_remove_attr(attr)
        " save selection registers
        new
        silent! put

        " get current highlight configuration
        redir @x
        silent! highlight
        redir END

为什么在你只关心字体的时候要包含整个.gvimrc文件? - Laurence Gonsalves
欢迎您编辑您认为多余的内容。我只保留了着色部分。 - vehomzzz
你是在询问颜色方案还是只有字体?如果是后者,那么“set guifont”这行代码就足够了。 - Laurence Gonsalves
5个回答

21

你可以使用:set guifont=*来打开字体选择对话框。一旦选定了字体,使用:echo &guifont查看在.gvimrc文件中应该输入什么(记得用\转义空格)。

个人喜欢Inconsolata。以下是我的.gvimrc设置:

set guifont=Inconsolata\ 13

+1 @Laurence G. Agh,我没有Inconsolata字体。你有推荐别的字体吗? - vehomzzz
您可能还想搜索“编程字体”。以下是一些不错的列表:http://hivelogic.com/articles/top-10-programming-fonts - Laurence Gonsalves
我仍然不知道你使用的操作系统/发行版是什么... - Laurence Gonsalves
在RedHat上,您可能希望使用RPM,例如这个:http://www.rpmfind.net/linux/RPM/fedora/devel/i386/levien-inconsolata-fonts-1.01-4.fc12.noarch.html - Laurence Gonsalves
另外,我相信将字体放在~/.fonts文件夹中可能会在RedHat上神奇地起作用。(您可能需要重新启动gvim - 我已经几年没有使用RedHat了,所以对于字体在那里的工作方式有点模糊) - Laurence Gonsalves
显示剩余3条评论

5

+1 for Consolas - 我已经使用它约6个月了,非常喜欢它。 - brettkelly

1

看看monofur - 这是一种非常不寻常的等宽字体。除此之外,我使用 Monaco。


1

这里有几个可能性的很好的比较链接

我曾经使用过ProggyCleanSZ(斜杠零版本),它是一种位图字体,只有在12号大小下才真正好看(尽管它与9-10号字体大约相同大小)。非常容易辨别0O,以及1Il之间的区别。但是我现在已经改用Envy Code R


链接已失效,请考虑更新此答案或将其删除。 - Fabrizio Regini
@FabrizioRegini - 感谢您的反馈:我已经修复了链接。 - DrAl

0

我更喜欢 Courier New 字体,它很好看。

我的 .vimrc 文件包含了这段代码片段来改变字体。

if has("gui_running")  
    if has("gui_gtk2")  
        set guifont=Courier\ New\ 10  
    elseif has("x11")  
        set guifont=-*-courier-medium-r-normal-*-*-180-*-*-m-*-*  
    else  
        set guifont=Courier_New:h10:cDEFAULT  
    endif  
endif   

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接