Vim:在函数内设置 GUI 字体
我不确定这是否是正确的方法,但事情就是这样。我想在深色方案和浅色方案之间切换我的 Vim。但是,colorscheme
并不是唯一需要切换的内容。我想切换字体,并且缩进引导颜色。所以我想出了这个函数:
fun! DarkScheme()
colorscheme molokai
set gfn=Monaco\ 10
call DarkIndentGuides()
endf
但是当我使用外部显示器时,我希望我的字体大于10。所以我想将字体大小作为参数传递。我已经尝试过,
fun! DarkScheme(n)
colorscheme molokai
set gfn="Monaco ".a:n
" and set gfn="Monaco\ ".a:n
" and also set gfn=Monaco\ a:n
call DarkIndentGuides()
endf
但它不起作用。它忽略任何这些示例中的字体大小。我该怎么做?谢谢!
I'm not sure that's right way to do this, but here's the thing. I want to switch my Vim between dark scheme and light scheme. However, the colorscheme
is not the only thing that should be switched. I want to switch the font, and indent guides color as well. So I've came up with this function:
fun! DarkScheme()
colorscheme molokai
set gfn=Monaco\ 10
call DarkIndentGuides()
endf
But when I'm using external monitor, I want my font to be bigger than 10. So I want to pass the font size as parameter. I've tried
fun! DarkScheme(n)
colorscheme molokai
set gfn="Monaco ".a:n
" and set gfn="Monaco\ ".a:n
" and also set gfn=Monaco\ a:n
call DarkIndentGuides()
endf
but it's not working. It ignores the font size in any of these examples. How do I do that? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您指定字体大小的方法对我不起作用。我使用
set gfn :h
(例如set gf=Monaco:h10
),所以我不确定为什么你的原始函数(使用硬编码字体大小)有效。要在此表达式中使用变量,您需要使用
execute
命令:这应该可以解决问题。
Your method of specifying the fontsize doesn't work for me. I use
set gfn <font>:h<size>
(e.g.set gf=Monaco:h10
), so I'm not sure why your original function (with the hard-coded font size) works.To use the variable in this expression, you need to use the
execute
command:which should do the trick.