简体   繁体   中英

how do I add a font in gVim on windows system

I wanted to add a UTF-8 font in Gvim but I could not find out how to do this. I tried to follow the step on this manual but it still did not work. http://www.inter-locale.com/whitepaper/learn/learn_to_type.html (vim section halfway the page)

Can anyone tell me how to add a font in Vim so I can have Japanese characters displayed ?

As others note, you must use a fixed-width font. Vim is a text editor, not a WYSIWYG editor.

If you have a fixed-width font with the characters you need then:

:set guifont=*

Select the font you want to use, the size, etc. Once you're happy with it, do:

:set guifont?

And it will output the current setting of the value. Put the set guifont=foo in your .gvimrc (or in .vimrc with a if has("gui_running") block).

set guifont=<C-R>=&guifont<CR>

That will put the current value into the file.

For Windows, I found using the guifontwide setting provided the expected functionality (ie mixed character display: Japanese, Chinese and English in the same file). This is not intuitive or obvious (at least not to me!) from the Vim help files, but having something like this in your startup settings will work:

set guifont=Consolas:h10 
set guifontwide=MingLiU:h10 "For windows to display mixed character sets
set encoding=utf-8 

Quote from the vim documentation :

For MS-Windows, some fonts have a limited number of Unicode characters. Try using the "Courier New" font. You can use the Edit/Select Font... menu to select and try out the fonts available. Only fixed-width fonts can be used though. Example:
        :set guifont=courier_new:h12

So, I guess, unless you find a fixed width font containing the characters you want to display, then you are out of luck.

This is what I use...

set gfn=MingLiU:h16:cDEFAULT
set fenc=utf-8
set encoding=utf-8

Put this in your _vimrc file, exit and reopen. Works like a charm for me. +T

You have to use a fixed-width font for Gvim under Windows.

There are several relevant pages at the Vim Tips Wiki:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM