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 04:51:03 01 March 2011, Tuesday
by Ben Schmidt:

> How do you figure that? You can easily get multiple buffers with
> buftype=help perfectly naturally by splitting help windows and moving to
> new help topics, using commands like ctrl-w ctrl-], and so on, and Vim
> behaves perfectly normally and as expected.
Just point me where help describes which of multiple buffers with 'bt' set to
`help' will be used to open new help topic? Also note that ``:h 'bt''' says that
you are not supposed to set 'buftype' to `help' manually.

> Well, my set should definitely have been setl, but apart from that, I
> think it's still arguably a better approach.
I would have agreed with you if it was described in a documentation: your
solution should delete buffers on window close, while my won't.

Original message:
> >> 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
>
> How do you figure that? You can easily get multiple buffers with
> buftype=help perfectly naturally by splitting help windows and moving to
> new help topics, using commands like ctrl-w ctrl-], and so on, and Vim
> behaves perfectly normally and as expected.
>
> >> (that is why I would have written `setl bt= | vert help
> >> subject' instead of suggested `vnew | set bt=help | help subject').
>
> Well, my set should definitely have been setl, but apart from that, I
> think it's still arguably a better approach.
>
> > The suggested pipe 'setl bt= | help' does indeed override Vim's miserly
> > behavior relative to help windows..
> >
> > Why?
>
> Because Vim identifies help windows by the buftype, so if you clear it,
> Vim no longer thinks it is a help window, so doesn't reuse it.
>
> I would advise against this, as it has other side effects, e.g. using
>
> :help in the existing window will not reuse it as desired, but open a
>
> new window. A few other help-window-specific behaviours will also not
> work on the old help window if you do this.
>
> > Another quick question.. in Vimscript, what is the natural idiom to code:
> >
> > if count == 0; do proc_0; fi
> > if count == 1; do proc_1; fi
> > if count> 1; do proc_n; fi
> >
> > Otherwise, is there a decent tutorial on how to write functions in Vim..?
>
> I'm not sure Vimscript has any natural idioms! You will probably get a
> whole bunch of opinions on how best to do anything. Quite possibly the
> best idiom is what seems most natural to you.
>
> But what you wrote above seems fine, though of course in Vimscript, the
> syntax is different:
>
> if count == 0 | call proc_0() | endif
> if count == 1 | call proc_1() | endif
> if count> 1 | call proc_n() | endif
>
> Ben.

No comments: