Monday, February 28, 2011

Re: using the help system in split screen mode

Reply to message «Re: using the help system in split screen mode»,
sent 23:32:26 28 February 2011, Monday
by Chris Jones:

> How could I figure out the number of help windows in the current tab?
let helpcount=len(filter(range(1, winnr('$')),
\'getbufvar(winbufnr(v:val), "&ft")==#"help"'))

You may want to change "&ft" (shortcut to "&filetype") to "&bt" (shortcut to
"&buftype"), but I would use &ft because vim behavior when you have more then
one buffer with 'buftype' set to `help' is undefined (that is why I would have
written `setl bt= | vert help subject' instead of suggested `vnew | set bt=help
| help subject').

Original message:
> On Sun, Feb 27, 2011 at 06:01:23PM EST, Ben Schmidt wrote:
> >> When I am editing a file rather than displaying a help subject, I issue
> >> a ':vhl topic' command (with vhl mapped to ':vertical help', and Vim
> >> vertically splits the screen and displays the topic's help file in
> >> a separate window, so that the buffer I am editing remains visible.
> >>
> >> Unfortunately, when I already have a help window open in the current
> >> tab, this does not work.
> >
> > This is a little more complicated, but I'm sure you can :map or :command
> >
> > or :cabbrev it:
> > :vnew | set bt=help | help subject
>
> Thanks, Ben.. The bt=help is probably what I was looking for.
>
> I'll set this up via a custom :Help command that will additionally take
> care of removing the scratch buffers. And possibly add some logic that
> counts the number of help windows in the current tab.. if zero: create
> a new tab, if one: do a vertical split on the current tab.. and if two
> or more... do horizontal splits.
>
> Not very flexible but it should cover my limited needs.
>
> How could I figure out the number of help windows in the current tab?
>
> Thanks,
>
> cj

No comments: