Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to know `preview` window opened(existed) in vim?

Tags:

vim

In fact, I just want to write a script to toggle preview window. But it seems can't archived from any internal setting of vim.

So, as title. I want to write a script to do it. Any one knows how to check preview window is opened(or existed)?

like image 755
naive231 Avatar asked Jan 13 '13 02:01

naive231


1 Answers

Check variable previewwindow or pvw(please refer to the link). A sample code would be:

fun! previewWindowOpened
    for nr in range(1, winnr('$'))
        if getwinvar(nr, "&pvw") == 1
            " found a preview
            return 1
        endif  
    endfor
    return 0
endfun
like image 64
Hui Zheng Avatar answered Sep 23 '22 11:09

Hui Zheng