我想用Vim来配置GUI的默认设置。我已经在网上做了一些研究,但我找到并尝试的所有解决方案都没有起作用。
以下是我尝试过的一些方法(在.vimrc文件中):
set guifont = Monaco:h20
set guifont=Monospace 20
实际上,我不在乎Monaco字体。
对于第一个,请去掉空格。对于set命令,空白符很重要。
set guifont=Monaco:h20
第二个应该是(h指定高度)
set guifont=Monospace:h20
我建议设置字体的方式是(如果您的版本支持)
set guifont=*
这将弹出一个菜单,让您选择字体。选择字体后,开始输入即可。set guifont?
显示当前的guifont设置。将该行复制到您的vimrc或gvimrc中。如果字体中有空格,请添加\
来转义空格。
set guifont=Monospace\ 20
:version
,它应该列出 Vim 查找文件的位置。它应该类似于 ~/.vimrc
、~/.vim/vimrc
、$HOME/_vimrc
。 - FDinoff在12
之前尝试加上一个\<Space>
,像这样:
:set guifont=Monospace\ 12
~/.gvimrc
中,它可以解决问题。"最初的回答"set guifont=Monaco:h20
guifont
:https://github.com/awvalenti/vim-simple-guifont。你的vimrc
应该像这样,它会处理所有特定于操作系统的内容:silent! call simple_guifont#Set(
['Cascadia Code PL', 'JetBrains Mono', 'Hack'], 'Consolas', 14)
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
cmd.exe
中运行wmic desktopmonitor get PixelsPerXLogicalInch /value
时会发生什么? - 9999years在语法中添加Regular并使用gfn
:
set gfn= Monospace\ Regular:h13
设置 guifont=Lucida\ Console:h10
set guifont=Ubuntu\ Mono\ 11
:help
代替;它更快且更权威。对于你的情况,一个简单的:help font<C-d>
就足够让你找到:help guifont
并学会如何正确地为你的系统设置set guifont
。 - romainl