Gvim 7.4: how to save the default font setting? Any improvements from gvim 7.3?

0

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.

John Sonderson

Posted 2013-11-02T19:20:35.097

Reputation: 2 816

1I simply have the following command in my _vimrc. Does this not work for you? set guifont=Courier_New:h10:cANSI – garyjohn – 2013-11-02T20:18:05.850

You must have that in your _gvimrc file though, correct, not in the _vimrc? – John Sonderson – 2013-11-03T13:53:45.110

1No, 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 – 2013-11-03T18:42:01.000

Thanks. Can you please tell me how come the character set section of this command does not include UTF-8 and what the difference is between specifying the character set here versus specifying it with :set encoding ? Thanks. – John Sonderson – 2013-11-03T23:49:56.007

1I 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 – 2013-11-04T17:43:41.103

Thanks. For some reason I wasn't receiving the rest of the mail from the vim mailing list, but I can see the answer here: https://groups.google.com/forum/#%21searchin/vim_use/sonderson/vim_use/X6_l_kIukrI/2fqvM3aeiWwJ . I guess forums are now available under Google Groups such as : https://groups.google.com/forum/#%21forum/vim_use

– John Sonderson – 2013-11-06T17:50:21.580

To quote Tony's answer: The 'guifont' setting has a number of different incompatible settings. If you only use Vim on Windows this is not of much concern to you, but there are at least two very different formats in current use on Linux, and there used to be one more. See http://vim.wikia.com/wiki/Setting_the_font_in_the_GUI

– John Sonderson – 2013-11-06T17:52:19.357

So basically this setting is incompatible. Probably vim should clean up this command's syntax since we already have the ":set encoding" command. – John Sonderson – 2013-11-06T17:53:08.770

I'm not following you. Is incompatible with what? The various 'guifont' settings are incompatible with each other because various window managers have incompatible methods of specifying fonts and usually have different fonts available. This is something Vim can't "fix" without coming up with Yet Another Font Specification Language. The solution that seems to work well it to use if has("...") in your vimrc to select 'guifont' depending on your GUI environment. I'm not sure that's what you mean by "incompatible", though. – garyjohn – 2013-11-06T18:35:11.763

OK, I was just referring to the fact that Gvim seems to offer functionality in two places rather than one for setting the character encoding. Namely, both with :set guifont=... (which has a field where besides the font, the encoding is specified as well, and a separate :set econding=... which also sets the encoding. I can't seem to figure out the difference between these two ways of setting the font. Why does vim allow the encoding to be set in two different places (i.e. using two different commands), rather than with one command? – John Sonderson – 2013-11-12T15:38:49.277

i.e., Why is gvim designed with two places where the encoding can be specified rather than one place which would make more sense to me? Thanks. – John Sonderson – 2013-11-12T15:39:26.263

1Where 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 – 2013-11-12T16:46:24.933

1... that includes a glyph, or an image, for that character. – garyjohn – 2013-11-12T16:47:10.390

Sorry about the late reply. Of course a character from an encoding can be rendered using different fonts. It's true, there is no encoding option in the GUI Font menu, but there is a Script option which does not make sense. What is the difference between encoding and script? And encoding for Russian encodes Russian and an encoding for Korean encodes Korean. Hence script should be redundant. This is the part I find confusing. – John Sonderson – 2013-11-23T17:47:48.433

Also, if you issue :help guifont in VIM you will see that it says cXX - character set XX. Valid charsets are: ANSI, ARABIC, ALTIC, CHINESEBIG5, DEFAULT, EASTEUROPE, ... This "character set" should correspond to what you descibe as the Script option in the GUI. – John Sonderson – 2013-11-23T17:50:51.153

I don't know what that Script setting does. It's not there in the Linux font dialog, so it's probably a Windows thing and I don't know anything about the details of Windows fonts. – garyjohn – 2013-11-23T21:05:43.170

Answers

1

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

Ravi G.

Posted 2013-11-02T19:20:35.097

Reputation: 11

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.

StahlRat

Posted 2013-11-02T19:20:35.097

Reputation: 101