tags:

views:

1215

answers:

7

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
+9  A: 

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
Laurence Gonsalves
+1 @Laurence G. Agh, I don't have Inconsolata. Another one you'd recommend?
vehomzzz
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 http://www.levien.com/type/myfonts/inconsolata.html
Laurence Gonsalves
You may also want to do some searches for "programming font". Here's a good list of some: http://hivelogic.com/articles/top-10-programming-fonts
Laurence Gonsalves
By "Andale" I meant "Andale Mono".
Laurence Gonsalves
I found the font: http://www.levien.com/type/myfonts/Inconsolata.sfdwhere do I put this or how to install it? thx
vehomzzz
I still don't know what OS/distro you're using...
Laurence Gonsalves
I am using redhat
vehomzzz
On RedHat you might want to use an RPM, like this one: http://www.rpmfind.net/linux/RPM/fedora/devel/i386/levien-inconsolata-fonts-1.01-4.fc12.noarch.html
Laurence Gonsalves
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)
Laurence Gonsalves
+1  A: 

I'm a big fan of Anonymous. I like to fit as much as I can on my screen, so my vimrc looks like:

set guifont=Anonymous:h8
James McNellis
+4  A: 

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

Kirill V. Lyadvinsky
+1 for Consolas - been using it for about 6 months now and I love it.
inkedmn
A: 
Brandon Thomson
A: 

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

Leonid Shevtsov
A: 

I prefer Courier New, its good..

my .vimrc includes this code snippet to change the font

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
Siva
+1  A: 

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

I 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.

Al