0

I often see that fonts intended to be used on Windows are defined with :cANSI.

set guifont=Consolas:h11:cANSI

The help is, of course, provide some explanation, but I don't really understand it.

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 and VIETNAMESE. Normally you would use "cDEFAULT".

Examples:

  • :set guifont=courier_new:h12:w5:b:cRUSSIAN
  • :set guifont=Andale_Mono:h7.5:w4.5

Here is my vimrc:

if has('multi_byte')
  if &encoding !~? '^u'
    if &termencoding == ''
      let &termencoding = &encoding
    endif
    set encoding=utf-8
  endif
  setglobal fileencoding=utf-8
  set fileencodings=ucs-bom,utf-8,cp1251,latin1
endif

" set guifont=Consolas:h11:cANSI
" set guifont=Consolas:h11
" set guifont=Consolas:h11:cRUSSIAN

I can use :h11:cANSI, just :h11, or :h11:cRUSSIAN, and I don't see any difference.

What is the reason to use :cANSI or :cRUSSIAN? Maybe this is something that was necessary in older versions of Vim only?

6
  • 1
    Charsets are not used with Unicode.
    – Matt
    Sep 16 at 18:11
  • @Matt Well, I expected something like this. But could you show or describe a case where their use is required? Using set guifont=Consolas:h11:cRUSSIAN with a clean vimrc, for example, doesn't provide a possibity to see Russian characters, such as д or ф.
    – jsv
    Sep 16 at 18:57
  • 1
    I think the charset is more or less vaguely explained by microsoft here: docs.microsoft.com/en-us/windows/win32/gdi/… Sep 16 at 19:08
  • 2
    @jsv Charset is only needed if &encoding is not Unicode one. For example, until very late Vim for Windows used default charset (i.e. set enc=cp1251 for Russian locale). Then cRUSSIAN charset for guifont will be required.
    – Matt
    Sep 17 at 4:25
  • @Matt I just tested set encoding=cp1251 guifont=Consolas:h11 with Vim 8.2.2824 and this works perfectly fine even without charset. (Thanks anyway.)
    – jsv
    Sep 17 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.