Friday, May 28, 2010

Re: Determine how many windows are on screen

Hello,

"David Fishburn" wrote :

> 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.

> [...]
>
> Suggestions?

I use the following:
http://code.google.com/p/lh-vim/source/browse/misc/trunk/vimrc_core.vim#516

If the len of the current buffer is null, and that there only one empty line, then I consider I'm sitting at this [No Name] buffer.
It also works after a :new.

HTH,

PS: you can also play with:
:echo len(filter(map(lh#buffer#list(), 'bufwinnr(v:val)'), 'v:val != -1'))
to obtain the list of opened windows and their number. But regarding what you are looking for, this is a very complex solution.
[lh#buffer#list() comes from lh-vim-lib, see my signature)

--
Luc Hermitte
http://lh-vim.googlecode.com/
http://hermitte.free.fr/vim/

--
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: