gpt4 book ai didi

vim - 在 Vim 的终端中获取列

转载 作者:行者123 更新时间:2023-12-04 19:47:03 25 4
gpt4 key购买 nike

我试图从 Vim 中获取终端大小,但调用 :!tput cols总是返回 80无论终端的实际大小。从终端运行命令返回正确的值。

有没有办法从 Vim 中获取终端中的列数?为什么上面的命令产生不正确的值?我猜这与 Vim 运行外部命令的方式有关。

还有$COLUMNS shell 变量,但看起来这些没有导出到子进程(vim),如下所述:LINES and COLUMNS environmental variables lost in a script

最佳答案

我找到 :set co返回列数。

'columns' 'co'          number  (default 80 or terminal width)
global
{not in Vi}
Number of columns of the screen. Normally this is set by the terminal
initialization and does not have to be set by hand. Also see
|posix-screen-size|.
When Vim is running in the GUI or in a resizable window, setting this
option will cause the window size to be changed. When you only want
to use the size for the GUI, put the command in your |gvimrc| file.
When you set this option and Vim is unable to change the physical
number of columns of the display, the display may be messed up. For
the GUI it is always possible and Vim limits the number of columns to
what fits on the screen. You can use this command to get the widest
window possible: >
:set columns=9999
< Minimum value is 12, maximum value is 10000.

关于vim - 在 Vim 的终端中获取列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37950595/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com