Friday, May 28, 2010

Determine how many windows are on screen

Vim 7.2.411

I am trying to determine via VimScript how many windows are on the
screen at the moment.
More specifically, I am trying to determine if a user just opened Vim
and they are sitting at the [No Name] buffer.
This could also be in a new tab.

If so, I would like to take over that buffer with something else rather
than creating a new buffer and end up having 2 buffers.

Looking through :h functions, I don't see anything jumping out to give
me a count of all windows.
What I think will work is parsing the output from winrestcmd().

1resize 32|vert 1resize 117|2resize 32|vert 2resize 117|3resize 65|vert
3resize 117|

Based on this output and simple regex to find '\<2resize\>' should do
it, but it just seems a bit of a hack.

That gets me to the point where I know we just have the one buffer.

Not really sure how to get rid of the [No Name] buffer and replace it
with my own.
:0r myfile

Results in [No Name] with the contents.
But what I really want is [No Name] gone and just myfile.

Suggestions?

TIA,
Dave

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: