gpt4 book ai didi

python - VIM:预览高度

转载 作者:太空宇宙 更新时间:2023-11-03 15:28:28 25 4
gpt4 key购买 nike

我是 vim 的新手,所以我试图为 vimrc 文件编辑一个现有的脚本。该脚本将获取当前缓冲区的内容并将其复制到新窗口中,然后运行 ​​Python。该脚本有效,但预览窗口始终是当前窗口的 50%。

这是脚本:

" Preview window for python
fu! DoRunPyBuffer2()
pclose! " force preview window closed
setlocal ft=python

" copy the buffer into a new window, then run that buffer through python
sil %y a | below new | sil put a | sil %!python -
" indicate the output window as the current previewwindow
setlocal previewwindow ro nomodifiable nomodified

" back into the original window
winc p
endfu

command! RunPyBuffer call DoRunPyBuffer2()
map <f5> :RunPyBuffer<CR>

我尝试了 set lines、set previewheight、set pvh、winc 10 -, ... 但似乎没有任何效果。那么有人知道如何更改预览窗口的高度吗?

最佳答案

您可以尝试在将其设置为“previewwindow”之前更改窗口高度:

" copy the buffer into a new window, then run that buffer through python
sil %y a | below new | sil put a | sil %!python -
" indicate the output window as the current previewwindow
setlocal winheight 20
setlocal previewwindow ro nomodifiable nomodified

更新:

我认为问题是当您更改设置时窗口高度已经设置好了。设置 'windowheight' 不会更改窗口的高度,它只会设置窗口允许的最小高度。

更好的解决方案是在使用 :new 创建窗口时指定窗口高度:

:below 10 new  "create a window of height 10

关于python - VIM:预览高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3173950/

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