Home  >  Article  >  System Tutorial  >  I'm running gVim7.3.1 on a GNU/machine

I'm running gVim7.3.1 on a GNU/machine

王林
王林forward
2024-02-09 11:45:12363browse

I'm running gVim7.3 on a GNU/machine. I would like to know if there is a way to manually change the font according to the size of the window. I am relatively new to VimLinux system modification command line font size, so I am new to Vim It's not familiar.

My situation is this: I use DejaVuSansMono12 as my default font, but sometimes I want to switch to Terminus9linux system to modify the command line font size, when I want to shrink the Vim window to see on the screen of content as I type. (You know, for those of us with small laptop screens who don’t want to switch between workspaces…!)

linux系统修改命令行字体大小_linux命令行字体调大_linux字体变大命令

So I want to know if I shrink the commands in the .vimrc file, if I shrink the default window size to small enough that Vim will manually adjust the font, will these behaviors happen manually.

linux命令行字体调大_linux字体变大命令_linux系统修改命令行字体大小

Any comments?

linux字体变大命令_linux系统修改命令行字体大小_linux命令行字体调大

When Vim's window size changes, Vim will trigger a VimResized storm. You can compile an autocmd that adapts to the font ('guifont'). This is an autocmd that only considers "columns" (not "rows" ”) and have a hardcoded font name:

linux命令行字体调大_linux系统修改命令行字体大小_linux字体变大命令

function! FontChangeOnResize()
if &columns > 80
set guifont=Lucida_Console:h14
elseif &columns > 60
set guifont=Lucida_Console:h12
elseif &columns > 40
set guifont=Lucida_Console:h10
elseif &columns > 20
set guifont=Lucida_Console:h8
else
set guifont=Lucida_Console:h6
endif
endfunction
autocmd VimResized * call FontChangeOnResize()

The above is the detailed content of I'm running gVim7.3.1 on a GNU/machine. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:itcool.net. If there is any infringement, please contact admin@php.cn delete