I am new to vim so I was trying to edit an existing script for the vimrc file. The script will take the content of the current buffer and copy it into a new window and开发者_如何转开发 then run Python. The scrip works but the preview window is always 50% of the current window.
This is the script:
" 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>
I tried set lines, set previewheight, set pvh, winc 10 -, ... but nothing seems to work. So does anybody know how I can change the height of the preview window?
You could try changing the window height before setting it to '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
Update:
I think the problem is that the window height is already set when you change the settings. Setting 'windowheight' does not change the window's height, it only sets the minimum height allowed for the window.
A better solution is to specify the window height when you create it with :new
:
:below 10 new "create a window of height 10
精彩评论