Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vim 不同尺寸的AutoCMD用于收缩和生长_Vim_Autocmd - Fatal编程技术网

Vim 不同尺寸的AutoCMD用于收缩和生长

Vim 不同尺寸的AutoCMD用于收缩和生长,vim,autocmd,Vim,Autocmd,每当调整vim应用程序窗口的大小时,autocmd VimResized*将运行命令。 根据调整大小是收缩还是增长,是否有方法运行不同的命令? 如果是这样的话,console vim是否有任何警告?窗口是二维的,因此收缩或增长的概念非常不精确:您是在谈论高度、宽度还是面积 假设你说的是这个区域 一个简单的方法是在启动时和每次调整win的大小时保存窗口的最后一个大小;然后,每次调整win的大小时,您只需比较上一个大小和新大小: " Defines a command to save the cur

每当调整vim应用程序窗口的大小时,
autocmd VimResized*
将运行命令
。 根据调整大小是收缩还是增长,是否有方法运行不同的命令?
如果是这样的话,console vim是否有任何警告?

窗口是二维的,因此收缩或增长的概念非常不精确:您是在谈论高度、宽度还是面积

假设你说的是这个区域

一个简单的方法是在启动时和每次调整win的大小时保存窗口的最后一个大小;然后,每次调整win的大小时,您只需比较上一个大小和新大小:

" Defines a command to save the current dims:
command! SaveVimDims let g:last_lines=&lines | let g:last_columns=&columns

" Saves the dims on startup:
au VimEnter * SaveVimDims

" Calls the func below, each the win is resized:
au VimResized * call VimResized_Func()

function! VimResized_Func()
    " Gets the area of the last dims:
    let last_area = g:last_lines * g:last_columns

    " Saves the new dims:
    SaveVimDims

    " Gets the area of the new dims:
    let cur_area = g:last_lines * g:last_columns

    " Compares the areas:
    if cur_area < last_area
        " do something when shrinking
    else
        " do something when growing
    endif
endf
“定义保存当前DIM的命令:
命令!SaveVimDims让g:last_line=&line |让g:last_columns=&columns
“启动时保存DIM:
au VIMCENTER*保存VIMDIMS
“调用下面的func,每次调整win的大小:
au VimResized*调用VimResized_Func()
函数!VimResized_Func()
“获取最后一个DIM的区域:
设last_area=g:last_lines*g:last_columns
“保存新的DIM:
SaveVimDims
“获取新DIM的面积:
设cur_面积=g:last_行*g:last_列
“比较以下方面:
如果当前区域<最后一个区域
“收缩时做点什么
其他的
“长大后做点什么
恩迪夫
endf

这只是用Gvim测试的。;我从未在控制台中使用Vim。希望它也能正常工作。

控制台Vim永远不会触发/接收该事件。@Romaill我已经在控制台Vim中触发了该事件。