7

As the following post demonstrates:

How to change the default font of gVim

on Windows 7 it is impossible to save the default Gvim font from the Gvim program. Closing Gvim will cause it to completely forget about all font settings, and it is not possible to set them in the _vimrc file.

Has this been fixed in Gvim 7.4 or does this bug persist? Or does anyone know of a better way to set the default font? Cause the FixedSys font sucks as it cannot display Czech characters, and I don't want to have to go to the menu to change it every time I open a file that contains Czech characters. Thanks.

** EDIT **

OK, now I see the documentation for setting the font by issuing the Gvim command

:help guifont

Here is what I found:

For the Win32 GUI                   *E244* *E245*
- takes these options in the font name:
    hXX - height is XX (points, can be floating-point)
    wXX - width is XX (points, can be floating-point)
    b   - bold
    i   - italic
    u   - underline
    s   - strikeout
    cXX - character set XX.  Valid charsets are: ANSI, ARABIC,
          BALTIC, CHINESEBIG5, DEFAULT, EASTEUROPE, GB2312, GREEK,
          HANGEUL, HEBREW, JOHAB, MAC, OEM, RUSSIAN, SHIFTJIS,
          SYMBOL, THAI, TURKISH, VIETNAMESE ANSI and BALTIC.
          Normally you would use "cDEFAULT".

  Use a ':' to separate the options.
- A '_' can be used in the place of a space, so you don't need to use
  backslashes to escape the spaces.
- Examples:  
    :set guifont=courier_new:h12:w5:b:cRUSSIAN
    :set guifont=Andale_Mono:h7.5:w4.5

so now for example from within Gvim I can do the the following:

:set guifont=Lucida_Console:h12:cDEFAULT

and I can put the command

set guifont=Lucida_Console:h12:cDEFAULT

inside C:\Users\JSonderson_gvimrc and this font family and font size and character set is loaded each time I start gvim.


However a question still remains, that is, how come UTF-8 is not on the list of character sets?

Isn't the character set something separate from the font anyways?

What's the difference between character set and character encoding?

How can I display the actual character set which is being used when I use the DEFAULT setting?

Thanks.

16
  • 2
    I simply have the following command in my _vimrc. Does this not work for you? set guifont=Courier_New:h10:cANSI
    – garyjohn
    Commented Nov 2, 2013 at 20:18
  • 1
    No, I do not have a _gvimrc file. That command worked when I put it in there, and it appears to still be working, but I will check my Windows system Monday again to be sure.
    – garyjohn
    Commented Nov 3, 2013 at 18:42
  • 1
    I just checked my Vim 7.4.52 running on Windows 7. The font used by gvim does indeed follow the guifont setting in my ~/_vimrc. As for the character set vs. encoding question, I think Tony answered that pretty well in your thread in the vim mailing list and better than I could do.
    – garyjohn
    Commented Nov 4, 2013 at 17:43
  • 1
    Where do you see encoding in the GUI Font menu? In both Windows and Linux, I see in that menu only settings for Font, Font style, Size and (on Windows only) Script. Encoding and font are different concepts. Encoding specifies the representation of characters in memory or in a file. Font specifies the look of characters on a display or page. To use gvim to view a file containing the Greek letter mu, for example, the bit pattern representing that character in the file must use some encoding that includes the character mu. To see that character on your display, you must use a font...
    – garyjohn
    Commented Nov 12, 2013 at 16:46
  • 1
    ... that includes a glyph, or an image, for that character.
    – garyjohn
    Commented Nov 12, 2013 at 16:47

3 Answers 3

6

On Windows 10, I had to add this line to _vimrc in user home directory to make font setting persistent: (Default set to Consolas size 10).

set guifont=Consolas:h10

2

On Windows 10, I used .vimrc in my home directory and it worked. I'm not sure what the "_" (underbar) in _vimrc is supposed to represent, but traditionally Unix programs will look for a filename that starts with a "." (period) not an underbar.

So in file:

C:\Users\Brenden\.vimrc

I added one line:

set guifont=Lucida_Console:h12

And that set the font and size for me.

0

I'm using GVIM 8.0.69. It comes with vimrc_example.vim which I've edited to add following line:

set guifont=Consolas:h10.

:saveas _guirc saves config file in default home folder GVIM.

Restarted. I have my new default font.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .