Change font size quickly

Change font size quickly - Vim Tips Wiki

Change font size quickly

Edit Talk0
1,612 pages on
this wiki

 

Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Tip 760 Printable Monobook Previous Next

created 2004 · complexity intermediate · author Wouter Bolsterlee · version 6.0


If you regularly switch to a larger or smaller font, for example because someone looking at your code thinks the letters are too small, or because you want to lay back in your chair while reading, this tip is for you.

The following script defines two commands, :LargerFont and :SmallerFont, to allow quick adjustments to the font size used in the gtk2 gui. Change minfontsize and maxfontsize to suit your needs. See below for alternative solutions.

To use this script, put the following code into ~/.vim/plugin/gtk2fontsize.vim or in your vimrc.

let s:pattern = '^\(.* \)\([1-9][0-9]*\)

let s:minfontsize = 6 let s:maxfontsize = 16 function! AdjustFontSize(amount) if has("gui_gtk2") && has("gui_running") let fontname = substitute(&guifont, s:pattern, '\1', '') let cursize = substitute(&guifont, s:pattern, '\2', '') let newsize = cursize + a:amount if (newsize >= s:minfontsize) && (newsize <= s:maxfontsize) let newfont = fontname . newsize let &guifont = newfont endif else echoerr "You need to run the GTK2 version of Vim to use this function." endif endfunction function! LargerFont() call AdjustFontSize(1) endfunction command! LargerFont call LargerFont() function! SmallerFont() call AdjustFontSize(-1) endfunction command! SmallerFont call SmallerFont()

posted on 2012-12-10 11:49  lexus 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lexus/archive/2012/12/10/2811105.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值