How do I set the default font size in Vim?

前端 未结 5 841
萌比男神i
萌比男神i 2020-12-04 07:22

I am trying to configure the default settings for my GUI with Vim. I already made research on the web, but all the solutions I found and tried did not work.

Here are

相关标签:
5条回答
  • 2020-12-04 07:28

    The other answers are what you asked about, but in case it’s useful to anyone else, here’s how to set the font conditionally from the screen DPI (Windows only):

    set guifont=default
    if has('windows')
        "get dpi, strip out utf-16 garbage and new lines
        "system() converts 0x00 to 0x01 for 'platform independence'
        "should return something like 'PixelsPerXLogicalInch=192'
        "get the part from the = to the end of the line (eg '=192') and strip
        "the first character
        "and convert to a number
        let dpi = str2nr(strpart(matchstr(substitute(
            \system('wmic desktopmonitor get PixelsPerXLogicalInch /value'),
            \'\%x01\|\%x0a\|\%x0a\|\%xff\|\%xfe', '', 'g'),
            \'=.*$'), 1))
        if dpi > 100
            set guifont=high_dpi_font
        endif
    endif
    
    0 讨论(0)
  • 2020-12-04 07:32

    I cross over the same problem I put the following code in the folder ~/.gvimrc and it works.

    set guifont=Monaco:h20
    
    0 讨论(0)
  • 2020-12-04 07:36

    For the first one remove the spaces. Whitespace matters for the set command.

    set guifont=Monaco:h20
    

    For the second one it should be (the h specifies the height)

    set guifont=Monospace:h20
    

    My recommendation for setting the font is to do (if your version supports it)

    set guifont=*
    

    This will pop up a menu that allows you to select the font. After selecting the font, type

    set guifont?
    

    To show what the current guifont is set to. After that copy that line into your vimrc or gvimrc. If there are spaces in the font add a \ to escape the space.

    set guifont=Monospace\ 20
    
    0 讨论(0)
  • 2020-12-04 07:42

    Add Regular to syntax and use gfn:

    set gfn= Monospace\ Regular:h13

    0 讨论(0)
  • 2020-12-04 07:53

    Try a \<Space> before 12, like so:

    :set guifont=Monospace\ 12
    
    0 讨论(0)
提交回复
热议问题