what is the good gvim guifont for C/C++ programming

12,026

Solution 1

You can use :set guifont=* to bring up a font chooser dialog. Once you've chosen a font use :echo &guifont to see what to put in your .gvimrc. (remember to \-escape spaces)

Personally, I like Inconsolata. From my .gvimrc:

set guifont=Inconsolata\ 13

Solution 2

Is it possible to use Consolas font there? It is the best monosize font I've ever seen.

Ok, it is possible. Check screenshot below:

image http://img.flashtux.org/upload/img132432527b55x895f9d81.png

Solution 3

Check out monofur - it's quite an unusual monospaced font. Other than that, I use Monaco.

Solution 4

There's a good comparison of a few possibilities here.

I used to use ProggyCleanSZ (the slashed-zero version), which is a bitmap font that only really looks any good in size 12 (although it's about the same size as a size 9-10 font). Very easy on the eyes though and easy to differentiate between 0 and O as well as 1, I and l. I have since switched to using Envy Code R.

Share:
12,026
vehomzzz
Author by

vehomzzz

He adapts a lazy approach to a complex learning. His eclectic personality coupled with eccentric character caused much harm to masses, and to himself.

Updated on July 17, 2022

Comments

  • vehomzzz
    vehomzzz almost 2 years

    I am trying to find an optimal font for gvim to program in C/C++.

    I currently have the following in ~/.gvimrc and I don't like it:

    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 [email protected]
        " 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
    
  • vehomzzz
    vehomzzz over 14 years
    +1 @Laurence G. Agh, I don't have Inconsolata. Another one you'd recommend?
  • Laurence Gonsalves
    Laurence Gonsalves over 14 years
    I also like Andale. What OS/distro are you using? On Ubuntu you can apt-get install ttf-inconsolata. On other systems you can download it from levien.com/type/myfonts/inconsolata.html
  • Laurence Gonsalves
    Laurence Gonsalves over 14 years
    You may also want to do some searches for "programming font". Here's a good list of some: hivelogic.com/articles/top-10-programming-fonts
  • Laurence Gonsalves
    Laurence Gonsalves over 14 years
    By "Andale" I meant "Andale Mono".
  • vehomzzz
    vehomzzz over 14 years
    I found the font: levien.com/type/myfonts/Inconsolata.sfd where do I put this or how to install it? thx
  • Laurence Gonsalves
    Laurence Gonsalves over 14 years
    I still don't know what OS/distro you're using...
  • Laurence Gonsalves
    Laurence Gonsalves over 14 years
    On RedHat you might want to use an RPM, like this one: rpmfind.net/linux/RPM/fedora/devel/i386/…
  • Laurence Gonsalves
    Laurence Gonsalves over 14 years
    Alternatively, I believe that dropping fonts in ~/.fonts might magically work on RedHat. (you may need to restart gvim -- I haven't used RedHat for a few years, so I'm a bit fuzzy on how fonts work there)
  • brettkelly
    brettkelly over 14 years
    +1 for Consolas - been using it for about 6 months now and I love it.
  • Fabrizio Regini
    Fabrizio Regini about 9 years
    Brokne links, please consider updating this answer or removing it.
  • DrAl
    DrAl about 9 years
    @FabrizioRegini - thanks for reporting: I've fixed the link.