我是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>
我尝试设置行,设置previewheight,设置pvh,winc 10 - ,......但似乎没有任何效果。那么有人知道如何更改预览窗口的高度吗?
答案 0 :(得分:4)
您可以尝试更改窗口高度,然后再将其设置为“预览窗口”:
" 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